Azure WebPubSub Private Endpoint Configuration for WebSocket Client

Shree 0 Reputation points
2024-05-08T08:53:04.9666667+00:00

Hi Azure Community,

I'm encountering an issue with my WebSocket client code when trying to connect to an Azure WebPubSub service using a private endpoint. The code works perfectly fine with a public endpoint but fails to receive messages when using a private endpoint.

Here's a simplified version of the client-side JavaScript code.

function socketInit(url, buttonId, inputWidgetId) {

Copy

console.log("Initializing WebSocket connection...");

var socket = new WebSocket(url, 'json.webpubsub.azure.V1');

socket.onmessage = function(evt) {

var message = JSON.parse(evt.data);

if (message.hasOwnProperty('data')) {

    if (message.data !== "") {

        document.getElementById(inputWidgetId).value = evt.data;

        document.getElementById(buttonId).click();

    }

}

};

}

When I inspect it, it shows an error like "Connection to 'wss://...' failed". I suspect the issue might be related to the network configuration or security settings associated with the private endpoint.

Could someone please guide me on how to troubleshoot and resolve this problem? Additionally, if anyone has successfully configured a WebSocket client to work with an Azure WebPubSub private endpoint, I would greatly appreciate any insights or tips you can provide.

Thank you in advance for your assistance!

Best regards, Shreenivas

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