Azure Web App - Opening Destination Socket Failed - Expected 101, got 400. #1986
Replies: 1 comment 3 replies
-
Have you read the documentation regarding deployment with Gunicorn and eventlet? Because you seem to be doing something different than the documented approach. Even after you address that, I have no knowledge of Azure so I don't know if you will be able to configure a load balancer that works with Socket.IO. The load balancing requirements are also documented, so I suggest you read the deployment section to learn about the specific complexities of deploying Socket.IO. |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi community
I have an issue with a Flask app deployed to an Azure App Service. I'm using Flask as the server-side and a JS Socket.IO client on a HTML page. The purpose (in a nutshell) of the app is to broadcast a subset of data that was previously written to an SQL DB using the emit() function of Flask-SocketIO. The data is emitted in a Python list. The JS on the client-side loops through a HTML table and dynamically updates the table based on the values contained in the SocketIO emit.
All aspects of the app work fine at a local level using socketio.run(app). Only once the app is deployed to Azure do I face issues.
I'd really appreciate any input from the community on what this could be. I thought I'd try this audience first, before heading to an Azure community.
Environment:
Python 3.9
Application in 'prod' is started in Azure with: gunicorn --bind=0.0.0.0 --worker-class eventlet --workers=5 --timeout=600 app:app
eventlet==0.30.2
Flask==2.2.2
Flask-Cors==3.0.10
Flask-SocketIO==5.3.3
python-engineio==4.4.1
python-socketio==5.8.0
Public face is HTTPS, server is HTTP. Azure does some sort of reverse proxying to provide the SSL layer.
Application initalisation:
app = Flask(__name__)
CORS(app)
socketio = SocketIO(app, cors_allowed_origins="*", logger=True, engineio_logger=True, async_handlers=True)
Code that broadcasts the data to all clients:
socketio.emit('update_table', data)
Snippet of the client-side code to initiate the Socket.IO connection:
var socket = io.connect(window.location.protocol + '//' + document.domain + ':' + location.port)
socket.on('update_table', function(data)...
Azure app stream logs (including SocketIO/engineio logs)
logs.txt
The client logs:

Beta Was this translation helpful? Give feedback.
All reactions