[Skygear Chat] Bug with multiple user channels



we are working with a self-hosted deployment (a docker setup) with skygear-server and skygear-chat. There is an iOS app (Skygear iOS SDK) which registers a user and an Angular application (Skygear JavaScript library) which register as well a user and then they communicate together in a group channel.

There is a bug that for some of the users we do not get the new messages in the angular app (if we reload the conversation, they are there, but we do not get informed even if we are subscribed). After some research we found out, that these users which are sometimes not working have 2 user channels in the database, but skygear loads only one per user and it is random which one (SQL query with Limit 1) (https://github.com/SkygearIO/chat/blob/b712e5c36df4086cc581e5f09ff6759410a762c6/chat/utils.py -> Line 26). If I manually delete one in the database, then user is working well.

Now my question:

  • Why does some users have one user channel and some have two?
  • Who exactly creates these channels and what are they used for?
  • Could you fix these problem by either prevent that multiple user channels are created or that you load all user channels when you want to inform the user?
  • Do we need to change something in our code so that these user channels are not created?

We would appreciate you help since this is a blocker for our application.

(This bug is the same as we mentioned in Problem with JS SDK message subscriprion, but back then, we did not have enough information to actually see what the problem was, and it was sometimes was gone since it works fine for some of the users).

Thanks for your help,


Hello Adrian,

A hotfix for the multiple user channel bug is recently released (Chat server v1.6.3: https://github.com/SkygearIO/chat/releases). Upgrading your chat server to v1.6.3 would have solved the problem.

To answer your question about user channel - user channel is created for every user in the chat app so that he can receive real-time messages. Whenever there are real-time message updates, Skygear would check who should receive the message and send it to the respective user channels.

Ten Tang


Hi Ten

Thanks for you answer, could you provide me the GitHub issue or at least a hint what you have done to solve this problem (query is still the same)?



Hello Adrian,

We’ve added a unique constraint to user channels at db level. https://github.com/SkygearIO/chat/commit/3f21a6cb3cf51a84eff560f387dd79f00e65fdc5

Let me know if the problem persists. If so we will take a look at the JS SDK.



Hi Ten

Ah perfect, and even the old channels are cleaned up. I updated to 1.6.3 and it works fine, the problem is gone. Thanks a lot for your help.