.NET - Azure Web PubSub - Real time message sent from server to a group, does not get received by clients in that group without protocol ( json.webpubsub.azure.v1 )

G, Prasad 1 Reputation point
2022-10-04T11:21:10.587+00:00

Trying to use Azure Web PubSub to send real time data from server and to receive the same in clients.
Created a WebsocketClient ( Client1 ) which does not uses protocol ( json.webpubsub.azure.v1 ).
Created another WebsocketClient ( Client2 ) which uses protocol ( json.webpubsub.azure.v1 ).
Both the clients are using two different ClientAccessUri ( Having access to join and send message to a group called 'TestGroup' ), the accessUrls are generated in server using negotiate endpoint with two different userId's.
Both the clients are started and joined the group 'TestGroup'.
Server sends a message to that group 'TestGroup', using SendToGroupAsync.
The sent message get received by Client2 only ( which is having protocol ) but not in Client1 ( which is not having protocol associated ).
But how can we get message in Client1? As it is not having protocol, Client1 should be able to communicate with server, while server sends a message to group ( as explained in microsoft doc below ).

https://learn.microsoft.com/en-in/azure/azure-web-pubsub/tutorial-subprotocol?tabs=csharp#using-a-subprotocol

Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
59 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Liangying Wei 756 Reputation points Microsoft Employee
    2022-10-10T04:42:02.12+00:00

    You can have your server add Client1 to the groupTestGroup using AddUserToGroupAsync when Client1 is joined.


  2. Liangying Wei 756 Reputation points Microsoft Employee
    2022-10-13T15:16:27.47+00:00

    Since client1 is not connected using subprotocol json.webpubsub.azure.v1, Client1 is not able to use such "joinGorup" command to join groups, such command is for the subprotocol only. For simple WebSocket clients, you can use server SDKs to join such clients to groups, please check https://learn.microsoft.com/en-us/azure/azure-web-pubsub/concept-service-internals#the-simple-websocket-client for detailed explanation about the simple WebSocket clients. And here contains SDKs that you can use for your server side to join this client to groups usingAddConnectionToGroup or AddUserToGroup: https://learn.microsoft.com/en-us/azure/azure-web-pubsub/reference-server-sdk-csharp

    0 comments No comments