Azure WebPubSub Private Endpoint Configuration for WebSocket Client

Shree 0 Reputation points

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) {


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

var socket = new WebSocket(url, '');

socket.onmessage = function(evt) {

var message = JSON.parse(;

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

    if ( !== "") {

        document.getElementById(inputWidgetId).value =;






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