How to allow websocket connetion in my Azure App Service wit Code publish mode?

Dengke Qi 20 Reputation points Microsoft External Staff
2025-02-17T07:12:53.49+00:00

I have created an Azure App Service in Code Publish mode. When I deploy a Flask server with port of 8000 in this app service, it works. But when I deploy a Flask-WebSocket server with port of 8000, the server starts successfully, but I can't get WebSocket connection in local with the app service. I wonder if the WebSocket connection can be translate from port of 443 to the port of 8000, and I want to open the port of 8000 in my App Service to resolve this issue.

So, what should I do to get the WebSocket connection from my App Service? Open the port of 8000, or other network setting in my App service?

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

Accepted answer
  1. Deepanshukatara-6769 16,565 Reputation points Moderator
    2025-02-17T07:32:10.53+00:00

    Hello , Welcome to MS Q&A

    To enable WebSocket connections in Azure App Service, make sure the WebSocket protocol is activated in your App Service settings. Azure App Service restricts opening custom ports like 8000 for external access. Instead, configure your application to listen on the default ports—80 for HTTP and 443 for HTTPS—and manage WebSocket connections through these ports.

    To enable the WebSocket protocol in your Azure App Service, follow these steps:

    Access the Azure Portal: Navigate to the Azure portal and locate your App Service.

    Go to Configuration: In the App Service menu, select the "Configuration" option.

    Enable WebSocket: Under the "General settings" tab, find the "WebSocket" option and ensure it is set to "On".

    This setting allows your App Service to support WebSocket connections. Make sure your application is also configured to handle WebSocket connections properly. If you need further assistance, refer to the Azure documentation on WebSocket support.

    Please let me know if you have any further questions

    Kindly accept answer if it helps

    Thanks

    Deepanshu


0 additional answers

Sort by: Most helpful

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.