Azure WebPubSub Service missed broadcast messages in group

Oz 0 Reputation points
2023-04-07T15:56:31.3133333+00:00

We have a carline checkout system, where school users:

  • Release coordinators
  • Teachers
  • Parents

use app to check-in to app and app sends real-time message on school uniquely created group so that all receive that parent has arrived, now release those students. To achieve real-time link we integrated azure webpub sub in our app. What we do is when parent/teacher/release-cordinators log into app we create one group per school and so that anything happens on their group all connected devices of this particular schools gets the message.

We are experiencing a strange issue where some of the clients dont receive live updates/messages. Here's my server side code that creates unique url for each client by binding into its school uuid. When each client logs in it gets its unique url and linked with its related group.

app.get('/negotiate', async (req, res) => {
    let userId = req.query.id;
    if (!userId) {
        res.status(400).send('missing user id');
        return;
    }
    let accessTokenRules = [`webpubsub.joinLeaveGroup.${req.query.uuid}`, `webpubsub.sendToGroup.${req.query.uuid}`];
    let token = await serviceClient.getClientAccessToken({ userId, "expirationTimeInMinutes": 1440, roles: accessTokenRules});
    res.json({
        url: token.url
    });
});

Later, this is how i send and receive from client side app:

const socket = new WebSocket(urlReceivedAbove, 'json.webpubsub.azure.v1');

socket.onopen = (evt) => {
     // when one client socket gets open i send a join group request to school group so that it start receiving/sending on that node
             
                        $('#fbConnectedIndicator').text(txt).show();
                        $('#fbConnectedIndicatorM').text(txt).show();
                    });
     socket.send(JSON.stringify({
           type: 'joinGroup',
           group: uuid, // same uuid of school so that it is in same group
           dataType: "json",
           data: {"methodName": "joiningGroup", "payLoad": ""}
     }));
};


socket.onmessage = (data) => {
// further processing 
}

Issue we are having when more than 200 people connected on one school group, some of the connected clients missed messages. Can we fix this or have some workaround on it?

Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
72 questions
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
942 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Grmacjon-MSFT 17,456 Reputation points
    2023-04-11T02:28:43.1+00:00

    Hi @Oz It looks like you posted the same question on Stack Overflow. A member from the Azure Web PubSub product group responded to your question. Posting on this platform for visibility: "Here is the JS client SDK that implements auto-reconnect and reliable message delivery on top of json.reliable.webpubsub.azure.v1 https://github.com/Azure/azure-sdk-for-js/tree/main/sdk/web-pubsub/web-pubsub-client Here is the quickstart using the client-side SDK https://learn.microsoft.com/azure/azure-web-pubsub/quickstart-use-client-sdk?tabs=javascript" Let us know if you have further questions. Best, Grace