92705102 avatar image
0 Votes"
92705102 asked ·

Can not connect to with websocket


This is my Azure NodeJS AppService's setup

Client side:

 const socket = io('', {
   withCredentials: true,
   forceNew: true,
   reconnectionAttempts: "Infinity", //avoid having user reconnect manually in order to prevent dead clients after a server restart
   timeout: 10000, //before connect_error and connect_timeout are emitted.
   transports: ['websocket']
 socket.on("notify", (msg) => {
       console.log("getting socket msg");
       this.get_socket_message = msg.message;

Server side:

 var io = require('')(server, {
   cors: {
     origin: "",
     methods: ["GET", "POST"],
     credentials: true,
   transports: ['websocket']
 console.log("getSocekt.js : ")
 var rtnMessage = { message: msg };
 io.emit('notify', rtnMessage);

But my client can not receive message from server or occasionally it can only receive first message, from the second onwards the "WebSocket is closed before closed before the connection is established" error message always shown.

I am using version 3.1.0 with NodeJS 14.15.1

How can I fix this ? Thank you very much

· 2
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@92705102 Thank you for your question. We apologize for the delay in getting back to you.

What tier of web apps are you using? For example, the free tier only allows for 5 websockets per instance. I see that your code allows for unlimited retries, and I wonder if you're hitting this limit. The standard tier has unlimited connections. Would you be willing to temporarily scale up to an S1 instance and try your test again? Please note that running higher tiers will generate additional tiers but you can scale back down after completing your tests.

For more information on these limits, please see here.

0 Votes 0 ·
92705102 avatar image 92705102 brtrachMSFT-0711 ·

I am using B2 plan. But I have to disconnect and reconnect every time send request to server to receive notification.

0 Votes 0 ·

0 Answers