The Technology
- Flask (Python)
- Flask-Socket.IO (using eventlet)
- WFastCGI
- IIS (Windows)
The Problem
I'm experiencing issues with Flask-Socket.IO whilst running on an IIS Web Server. I'm new to WebSockets so I'm well aware that I'm probably just doing something wrong - most likely something obvious.
A Bit of Background
I've managed to successfully implement Flask-Socket.IO on my development server, and it works flawlessly every time (even running locally on the same machine as the production server). However, when I try to run it on the IIS Web Server, I just can't get it to work at all. The rest of the app runs perfectly fine, but any parts that make use of Socket.IO result in repeated calls to the WebSocket with the following error:
WebSocket connection to '<URL>' failed: WebSocket is closed before the connection is established.
...amongst a bunch of failed POST
and GET
requests to: <DOMAIN:PORT>/socket.io/?EIO=4&transport=polling&t=...&sid=...
What I've Tried (to no avail):
- Installing
WebSocket Protocol
for IIS (tried settingenabled
to bothtrue
andfalse
) - Initialising Socket.IO with:
socketio.init_app(app, cors_allowed_origins="*")
(just for testing, to see if it resolved the issue) [spoiler: it didn't] - Uninstalling
eventlet
and installinggevent
instead - Reading everything there is to read online
- Staring into the abyss of late-night confusion and wondering why I do this to myself.
The Everlasting Frustration
As you can probably tell, I'd quite like to get this one resolved now so I can move onto the next thing that invariably won't work :)
Does anybody have any suggestions? They would be much appreciated.
Thanks