Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

Flask-SocketIO rejects the client: unsupported version of the Socket.IO or Engine.IO protocols

Your error

The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO)2 more lines it can show

Fix it fast

Most common cause, 1 of 3

The browser loads a Socket.IO 1.x or 2.x JavaScript client

Move the page to a 4.x client.

Fix
<script src="https://cdn.socket.io/4.8.4/socket.io.min.js" integrity="sha384-fBrXvbDtHoeKWJ/hcA6M+YGueiDW+h45I7V6F2kD1S8bOkrF9rZYPLVkCR6BLR/1" crossorigin="anonymous"></script>

# or, in a bundled front end
npm install socket.io-client@4
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

"The client is using an unsupported version of the Socket.IO or Engine.IO protocols" comes from python-engineio 4.x under Flask-SocketIO 5.x, which accepts a new connection only with EIO=4 in the URL. The client is a Socket.IO 1.x or 2.x JavaScript bundle, a plain WebSocket tool aimed at /socket.io/, or python-socketio 4.x. Move it to Socket.IO 4.x or python-socketio 5.x.

  • Applies to Flask-SocketIO 5.7, python-socketio 5.18, python-engineio 4.15, Socket.IO JavaScript client 4.8
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Look at the EIO value in the failing request URL (Network tab, or the server's access log), then list the Python packages. EIO=3 points to a 1.x or 2.x client, a request with no EIO at all points to a client that is not Socket.IO.

Run this first
python -m pip show flask-socketio python-socketio python-engineio | grep -E "^(Name|Version)"
curl -s "http://localhost:5000/socket.io/?EIO=4&transport=polling"

Then find the line you see in this list and open its fix:

  1. 1The browser loads a Socket.IO 1.x or 2.x JavaScript clientThe polling URL in the Network tab contains EIO=3
  2. 2A plain WebSocket client is pointed at the /socket.io/ pathThe request URL has no EIO parameter at all, for example ws://localhost:5000/socket.io/ from the browser WebSocket API, wscat or a raw WebSocket tab in an API tool
  3. 3A Python client built on python-socketio 4.x connects to a 5.x serverThe browser works, but a worker, a test or a device script running socketio.Client() is refused

What does the error look like?

  • The client is using an unsupported version of the Socket.IO or Engine.IO protocols (further occurrences of this error will be logged with level INFO)
  • "The client is using an unsupported version of the Socket.IO or Engine.IO protocols"
  • GET /socket.io/?EIO=3&transport=polling 400 (BAD REQUEST)

Cause 1 of 3

The browser loads a Socket.IO 1.x or 2.x JavaScript client

You seeThe polling URL in the Network tab contains EIO=3

Check

The unsupported-version error with EIO=3 in the URL means an old JavaScript client: the compatibility table in the Flask-SocketIO docs pairs JavaScript clients 1.x and 2.x with Flask-SocketIO 4.x, and clients 3.x and 4.x with Flask-SocketIO 5.x. An old script tag copied from an older tutorial, or a package.json pinned to socket.io-client 2, keeps sending the old protocol to the new server.

Check
grep -rn "socket.io" templates/ static/ --include=*.html | grep -i "script"
npm ls socket.io-client

Fix

Move the page to a 4.x client. With a script tag, load the current bundle from the Socket.IO CDN; with npm, install the current socket.io-client. Pinning the server back to the 4.x line also works, but it leaves you on unmaintained releases.

Fix
<script src="https://cdn.socket.io/4.8.4/socket.io.min.js" integrity="sha384-fBrXvbDtHoeKWJ/hcA6M+YGueiDW+h45I7V6F2kD1S8bOkrF9rZYPLVkCR6BLR/1" crossorigin="anonymous"></script>

# or, in a bundled front end
npm install socket.io-client@4

Verify

Hard-reload the page. The polling request now carries EIO=4 and returns 200, and the server log shows a new connection instead of the error.

Verify
curl -s "http://localhost:5000/socket.io/?EIO=4&transport=polling"

Confirmed by flask-socketio.readthedocs.io

Did this fix it?

Cause 2 of 3

A plain WebSocket client is pointed at the /socket.io/ path

You seeThe request URL has no EIO parameter at all, for example ws://localhost:5000/socket.io/ from the browser WebSocket API, wscat or a raw WebSocket tab in an API tool

Check

The unsupported-version error with no EIO parameter means a plain WebSocket client reached the Socket.IO endpoint, because the engine checks the query string before anything else. A request with no session id and no EIO=4 is refused with this message, so a bare WebSocket that does not speak the Engine.IO handshake can never get through.

Check
grep -rn "new WebSocket(" static/ templates/

Fix

Talk to the server with a Socket.IO client library instead of a raw WebSocket, in the browser and in test scripts alike. If the other side truly has to be plain WebSocket, it needs a plain WebSocket endpoint, not Flask-SocketIO.

Fix
// browser, after loading the 4.x client
const socket = io("http://localhost:5000");
socket.on("connect", () => console.log("connected", socket.id));

Verify

The connect handler fires and the server logs the session, with no 400 response for the upgrade.

Verify
python app.py

Confirmed by github.com

Did this fix it?

Cause 3 of 3

A Python client built on python-socketio 4.x connects to a 5.x server

You seeThe browser works, but a worker, a test or a device script running socketio.Client() is refused

Check

The unsupported-version error for a Python client means python-socketio 4.x on that machine: it speaks Engine.IO protocol 3, while the 5.x line speaks protocol 4. The python-socketio docs advise running the same version of the package on both ends.

Check
python -m pip show python-socketio python-engineio | grep -E "^(Name|Version)"

Fix

Upgrade the client machine to the 5.x line. The client extra installs the standard client together with the packages it depends on; for an asyncio client use the asyncio_client extra instead.

Fix
python -m pip install -U "python-socketio[client]"

Verify

Run the client script again; its connect handler prints and the server no longer logs the unsupported version line.

Verify
python client.py

Confirmed by python-socketio.readthedocs.io

Did this fix it?

How do I stop it coming back?

  • Pin the JavaScript client and the Python server packages together in your lock files, and upgrade them as a pair.
  • Load the client bundle from one shared template partial, so no old script tag survives in a forgotten page.
  • Keep a curl check of /socket.io/?EIO=4&transport=polling in your deploy smoke test.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine on the same stack: stegnor.com, TaxiDex, SessionBird.

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.