azure-webpubsub icon indicating copy to clipboard operation
azure-webpubsub copied to clipboard

User not found returned by Azure web pubsub rest api

Open vicancy opened this issue 4 years ago • 3 comments

<Copied from https://docs.microsoft.com/answers/answers/482267/post.html >

We have created the webhooks for /connect and /connected in our server and we get those endpoints called when client connects to pubsub using websocket. We want to add the connected user to be added to certain pubsub groups and we do that in /connected webhook. The problem is sometimes the pubsub rest api throws User not found error when trying to add the user to a group.

If addition of user to the group fails, the server disconnects the current connection and the client reconnects. This is resulting in an endless loop of client reconnection since the pubsub rest api constantly throws "User not found" in /connected webhook.

Solutions we have tried:

Add user to group in /connect endpoint instead of /connected. Same error gets thrown.

Add connection to group instead of user. We are currently monitoring that and would get back with our observation.

Note: The server is not using pubsub rest api directly. Its using azure messaging python sdk. Rest API [here](https://docs.microsoft.com/en-us/rest/api/webpubsub/web-pub-sub/add-user-to-group}

vicancy avatar Jul 21 '21 01:07 vicancy

The problem is sometimes the pubsub rest API throws User not found error when trying to add the user to a group.

This sounds like a service bug that the user is not yet completely registered when the connected event is triggered. Are you using Free tier or Standard tier? Does it happen frequently? It would be appreciated if you could provide a min-repro project/steps.

There is one convenient way to add the connection to a group when /connect, to leverage the CloudEvents response groups in the connect response body: https://github.com/Azure/azure-webpubsub/blob/main/docs/references/protocol-cloudevents.md#success-response-format

The property provides a convenient way for users to add this connection to one or multiple groups. In this way, there is no need to have an additional call to add this connection to some group.

vicancy avatar Jul 21 '21 01:07 vicancy

I experience the same issue. I'm getting this error while I'm adding a user to a group in connect as well as in connected function.

karolinadebowska avatar Apr 28 '23 11:04 karolinadebowska

in connected it should work, could you share the repro steps?

in connect it is expected that it could not work because connect event is triggered when the connection is connecting, it could be possible that when "addUserToGroup" is invoked in the service, the connection is not yet established. Please note that "AddUserToGroup" adds currently existing connections belonging to this user to the group.

vicancy avatar May 04 '23 07:05 vicancy