[SOLVED] Do Not Receive Team Websocket Events

Summary

As a logged in user who is a member of the team and a member of the channel I do not get posted websocket events.

Steps to reproduce

I am using Mattermost 3.10 API. I create a user through the API, assign them to a team and then setup a websocket for them. For channels I am currently a part of or those I join during the session I do not get websocket posted (or channel joined) events. I do get the hello and status events.
On the same Mattermost installation using the standard web-ui I can login as this user and receive the correct websocket events.

Expected behavior

I would expect to get the websocket events.

Observed behavior

I don’t get the websocket events.

To be honest - I am quite confused about the flow when using Mattermost entirely via the API - possibly due to the now day and a bit I have spent slamming my head against the wall with this issue.

Our process is as follows: Try to login -> if failed create user and login -> try to join team -> if failed create team and join team -> try to join channel -> if failed create channel and join.
I have not been using the view or stats endpoints so far (which the UI does) however I have manually triggered these and not seen any change in the websocket events returned. Furthermore - it seems very strange that I get the correct events when using the standard Mattermost UI for the same user.

Finally, I have one user account on my backend WHICH DOES get the correct websocket events, however, I am unsure of what I did differently when creating this user. Worse - when I join a channel as this user (through the API or otherwise) the websocket events not only start working for them but for all other users as well.

I am at my wits end with this one. I feel like the only place that there can be an issue is the login process - maybe I am missing a step when joining the teams?

Sorry for the wall of text - I should probably go to bed but I am stubborn and sick of this not working when it’s so close to working.

I have resolved my own issue. It turns out my cookies were not being set correctly on my application - this meant that when I logged in via the Platform UI the cookies were being set for my browser and these same cookies were being used by my websocket (explaining why it worked for one user consistently and others sporadically).

I have fixed it by switching to using the token method on websockets.

Thanks for posting back your solution @borigthedwarf!