Azure is blocking webSocket connect requests to my server test app on free tier compute platform

Michael Gaddis 11 Reputation points
2022-11-14T22:41:59.267+00:00

I'm building and testing client server communications via webSockets between a web client (current running on a local host) based on React/Node.js/Javascript and a server that I run on both the local environment on localhost port 80 and also on Azure on port 80. Works great on the local dev environment, been able to develop a robust client server protocol. But when I post the same server to Azure it fails to receive the http connection upgrade request (to webSocket which I require) on port 80. I reply to port 8080 for Azure to authenticate the app and launch it. I am able to verify the app is running and that it responded to 8080.

The documentation (though badly out-of-date in some places) says that webSockets are supported on a free tier compute (https://learn.microsoft.com/en-us/troubleshoot/azure/app-service/faqs-app-service-linux#web-sockets) but I'm suspecting that some knob needs to be turned here. Although the documentation says it's unnecessary to set WEBSITES_PORT since port 80 is the default port I still put the option on my configuration for WEBSITES_PORT = 80.

What gives?

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,939 questions
{count} votes

2 answers

Sort by: Most helpful
  1. LEANDRO DARIVA PINTO 16 Reputation points
    2023-01-27T10:56:31.7166667+00:00

    Hi Michael,

    I was strugling with making a app that use webscoket protocol to work for the past two months. To test it I created the dummiest possible app to see the websocket working. It is just a push buttom and a progress bar. The environment I was devoping was in my company azure and I am using Python Flask and Vanila JS. Initially I though that something could be wrong in my client JS side so I ask some help from MS. They took my code and made it work. They sent me their code and I tried and got the same connection error. So I deceided to test it with my azure personal account and it worked! I tested my original code and it worked too. So I think that there is some configuration on azure blocking websocket in some way, maybe for security reasons. I didn't find yet what is wrong but I will let you know if a find it out.

    Hope this can help you in some way.

    1 person found this answer helpful.

  2. SnehaAgrawal-MSFT 22,706 Reputation points Moderator
    2022-11-17T10:13:17.313+00:00

    Thanks @Michael Gaddis for reaching here! For web sockets in Node.js application could you please set Yes, disable perMessageDeflate in your server-side Node.js code

    Example, if you are using socket.io, use the following code:

    const io = require('socket.io')(server,{  
      perMessageDeflate :false  
    });  
    

    Let us know.

    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.