Negotiated url is not working while connecting to Azure webpubsub for socketio

Devender Singh 25 Reputation points
2025-03-18T04:45:37.5933333+00:00

I have a client and .net API and an azure webpubsub resource for socketio. I am trying to connect to pubsub via negotiated url.
Clinet (js) hits '/negotiate' endpoint of APi which generates negotiated url using

        _webPubSubServiceClient = new WebPubSubServiceClient(hubConnectionString, "socketio"); // Specify the hub name as "chat"

var uri = _webPubSubServiceClient.GetClientAccessUri(
            userId: "Dev");

        var url = uri.AbsoluteUri.Replace("https://", "");

        return Ok(new { url });

The negotiate url recieved by client is

'wss://azurepubsubforsocketio.webpubsub.azure.com/client/hubs/socketio/access_token=<....>'

While the 'Client URL generator' in pub sub resource shows below

User's image

where path is '/Clients/socketio/hubs/socketio' which doesnot match with negotiated url format as mentioned before.

That is the issue, now client is not able to connect to pubsub.
And got below error in tracing tool:

{"time":"2025-03-18T04:03:17.8239513Z","logLevel":"Error","eventName":"AudienceValidationFailed","message":"Failed to validate audience. Expected Audiences: azurepubsubforsocketio.webpubsub.azure.com/clients/socketio/hubs/socketio, azurepubsubforsocketio.webpubsub.azure.com:443/clients/socketio/hubs/socketio. Actual Audiences: https://azurepubsubforsocketio.webpubsub.azure.com/client/hubs/socketio.","exception":null,"ip":"2401:4900:1cb2:859c:817c:a5c:2ceb:9d62"}

  • The actual audiance is coming from negotiated url generate by azure sdk, suggest me solution.
Azure Web PubSub
Azure Web PubSub
An Azure service that provides real-time messaging for web applications using WebSockets and the publish-subscribe pattern.
97 questions
{count} votes

1 answer

Sort by: Most helpful
  1. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2025-04-11T11:38:55.3333333+00:00

    @Devender Singh

    Update- For C#, the team is actively working on releasing a new SDK version that will support Socket.IO as a request type. While progress is being made, we’re currently unable to provide a fixed ETA.

    For Node.js, the @azure/web-pubsub 1.1.4 already supports Socket.IO through the WebPubSubClientProtocol type in the getClientAccessToken() method.

    You can refer to the documentation here: https://learn.microsoft.com/en-us/javascript/api/%40azure/web-pubsub/webpubsubclientprotocol?view=azure-node-latest

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.