Closed kalaersun closed 3 years ago
It's exactly what the error says. The version of the Socket.IO client that you are using is incompatible with the version of the server. Either upgrade your client, or downgrade your server. The README of this repo has a table that shows you which JS and Python versions are compatible.
It's exactly what the error says. The version of the Socket.IO client that you are using is incompatible with the version of the server. Either upgrade your client, or downgrade your server. The README of this repo has a table that shows you which JS and Python versions are compatible.
socket.io-client 3.0.4 as client python-socketio 5.0.0 as server i use this two i don not konw where is the porblem
What is the problem? Are you still getting complains about unsupported versions?
What is the problem? Are you still getting complains about unsupported versions? i just don't know how to find whick version i should use
Pick any line in that table and use those.
I think I've found a solution as I've just had to deal with this issue. I believe it's due to our lovely miguelgrinberg also updating the python-engineio just make sure you pull 3.13.2 if your using say 4.6.1. Otherwise 4.0.0 python-engineio will be pulled which is causing incompatibility issues.
Can confirm @zkquin observation. Helped me fixed my issue.
If anyone's running into this because their app had a dependency on Flask-SocketIO and it's suddenly breaking, the issue is that there was a bug in the Flask-SocketIO setup.py prior to 4.3.2 that upgraded to any version of python-socketio >= 4.x. This was fine until python-socketio 5.x came out, which is not compatible with JavaScript socket.io clients on 1.x or 2.x.
@miguelgrinberg fixed this in this commit:
https://github.com/miguelgrinberg/Flask-SocketIO/commit/59740d3eb50395f44cfb786b85215b4ec9b795e9
He pushed that change to PyPi in Flask-SocketIO release 4.3.2.
For Flask-SocketIO 4.x clients, change your requirements.txt or setup.py to depend on Flask-SocketIO to 4.3.2.
there was a bug in the Flask-SocketIO setup.py
This is not a bug. The change to setup.py was made as soon as I knew that the next version of python-socketio was going to be backwards incompatible. The bug is in your application that does not pin all your dependencies.
The fix that you propose will just save you this time, but leaves you open to suffer from this problem again in the future.
The correct fix is this: once you get everything to work, run pip freeze > requirements.txt
to record the versions of all your dependencies (including indirect ones) in your requirements file and then you will never have this problem again.
This is not a bug. The change to setup.py was made as soon as I knew that the next version of python-socketio was going to be backwards incompatible.
Sorry, I'm not sure what you mean. If I pip install Flask-SocketIO==4.3.0
in a brand new virtualenv and run it against a 2.x JavaScript Socket.IO library, it will fail. That's a bug unless I'm misunderstanding the situation.
I'm not trying to cast blame. I was just trying to save other Flask-SocketIO clients time because it took me 30-40 minutes to understand what happened.
I agree with the technical decisions you've made, and I appreciate all your work on these libraries. I signed up as a Patreon sponsor after making my earlier comment to show my support.
once you get everything to work, run
pip freeze > requirements.txt
Cool! I didn't realize pip offered this. That's a useful thing to know. Thanks for sharing!
Sorry, I'm not sure what you mean. If I pip install Flask-SocketIO==4.3.0 in a brand new virtualenv and run it against a 2.x JavaScript Socket.IO library, it will fail. That's a bug unless I'm misunderstanding the situation.
Of course, but that version of Socket.IO is old. It was released at a point in time when it was not known that there would be a backwards incompatible version coming. If you are installing Flask-SocketIO today, you should install the current version, not an old version, and that would give you the correct dependencies, which you should save to a requirements file so that in the future, when this version becomes old you can restore a working environment. Today there is absolutely no reason to install that version in a new project.
I think I've found a solution as I've just had to deal with this issue. I believe it's due to our lovely miguelgrinberg also updating the python-engineio just make sure you pull 3.13.2 if your using say 4.6.1. Otherwise 4.0.0 python-engineio will be pulled which is causing incompatibility issues.
Funcionou pra mim 0/ Estava a 3 dias procurando o motivo rsrs
I still seem to be missing something? But what could it be?
[marcel@knaagbeest ~]$ pacman -Q python-engineio
python-engineio 4.0.0-1
[marcel@knaagbeest ~]$ pacman -Q python-socketio
python-socketio 5.0.2-1
[marcel@knaagbeest ~]$ pacman -Q python-flask-socketio
python-flask-socketio-git 4.3.2-1
[marcel@knaagbeest ~]$ curl https://x.x.x.x/socket.io/?transport=polling
"The client is using an unsupported version of the Socket.IO or Engine.IO protocols"
@mischa85 First of all, you can't pick and choose which versions of these packages you install, since different versions aren't always compatible. Install the most current version of flask-socketio and let the package manager bring the dependencies.
Second, what did you expect to happen? You are using curl
(which is not a Socket.IO client) to connect to a Socket.IO service. The server is saying that the client cannot speak a known version of the Socket.IO/Engine.IO protocols, and that is exactly right.
@miguelgrinberg Thanks for the quick answer and sorry for being a noob over here. I'm just trying to make another package working flask-nginx-rtmp-manager
, which started acting up RuntimeError: Redis requires a monkey patched socket library to work with eventlet
. Even on the original requirements.txt
versions. Seriously spitting in the logs and even worse, restarting the streaming server every 30 secs.
That error was gone when I installed a 4.x version of python-eventio instead of 3.x, but that error is suddenly back now even on python-eventio 4.x so I'm back to square one.
On-topic: The javascript socketio 2.x was cached in my browser. Replacing it with js socketio 3.x which results in: Invalid session 9zs9Gte3KMTfprobAAAC
But with the original monkey error back this is now the least of my problems.
@mischa85 Once again the error message is correct. These errors are intended to stop you from doing things wrong. Why are you not monkey patching? It is required for Redis to work.
My requirements.txt
file contains fixed version to 4.6.0
, yet all my v2.x clients can't suddenly connect to the server after building the exact same version with no changes to list of dependencies, receiving 403
due to the "unsupported version" error.
...
python-socketio==4.6.0
You can't be serious, how am I supposed to downgrade the server now?
@mischa85 Once again the error message is correct. These errors are intended to stop you from doing things wrong. Why are you not monkey patching? It is required for Redis to work.
It should be done by Gunicorn which is running and which is actually reporting the error, but is failing the monkey patching for some reason. I will file a bug report for the original error over there.
I will also try to reinstall everything and will report back over here if the socket.io error still appears.
For anybody wondering, I don't trust anything else than pacman to manage anything on my filesystem, even though an upgrade might have triggered all of this. Seeing the state of the Python ecosystem I have good reason not to use pip.
@mmajko What version of python-engineio do you have in your requirements.txt file? If you need to fix this, then uninstall python-socketio and python-engineio and then run the following:
pip install "python-socketio<5"
And this will give you a working set up that works for v2 clients. Then, save your requirements (including the versions of the dependencies), so that this does not happen to you again next time!
@mmajko What version of python-engineio do you have in your requirements.txt file?
None. My code depends solely on the python-socketio
package, which is installed according to the documentation.
... uninstall python-socketio and python-engineio and then run the following:
I'm running the builds isolated in Docker environment, there's no use to uninstall anything.
@mmajko The requirements.txt file does not only need to have the dependencies of your application. You also need to record the indirect dependencies needed by your own dependencies. See https://pip.pypa.io/en/stable/user_guide/#repeatability.
As I said above, to fix this you need to install the latest 4.x version of python-socketio, let pip bring in compatible dependencies, then update your requirements.txt file with the output of pip freeze
to have every dependency pinned.
@mmajko The requirements.txt file does not only need to have the dependencies of your application. You also need to record the indirect dependencies needed by your own dependencies. See https://pip.pypa.io/en/stable/user_guide/#repeatability.
As I said above, to fix this you need to install the latest 4.x version of python-socketio, let pip bring in compatible dependencies, then update your requirements.txt file with the output of
pip freeze
to have every dependency pinned.
I see. Not this package's fault then, but must say I'm genuinely disappointed with package management in Python.
Thanks for the help, hope it helps someone else too.
I'm genuinely disappointed with package management in Python
there are a lot of things you can complain about in Python packaging, but this isn't one of them. The only way to achieve repeatable installs in any language is to pin every dependency to a known working version. Some package managers do it automatically (npm for example), pip
requires you to do it. If you prefer something automatic, use a more sophisticated tool to manage your dependencies, such as poetry, pipenv, etc.
there are a lot of things you can complain about in Python packaging, but this isn't one of them. The only way to achieve repeatable installs in any language is to pin every dependency to a known working version. ...
Which is what I did, in fact. I've pinned the versions of all dependencies of my project. I shouldn't be responsible for pinning all transitive dependencies, which aren't explicitly used in the project code. Each dependency should have pinned versions of its dependencies too.
But hey, let's continue this discussion elsewhere, this is not the right place. Thanks again for your help.
@mmajko That's not how things work. What you are suggesting (each library pinning its dependencies) would make almost every installation impossible. You will have a lot of conflicts when library A needs version 1.2.3 of some dependency, and library B needs version 1.2.4. Libraries are supposed to work with a range of versions for their dependencies, your application is the correct place to do the pinning. And as I said, there some more sophisticated Python package managers that do this for you if you don't want to do it yourself.
I'm still getting the same error. I'm using the second row of the version compatibility as a reference. I followed @zkquin comment to pull version 3.13.2 of python-engine and upgraded Flask Socket io.
Python version: 3.8.3
Server
Flask-SocketIO==4.3.2
python-engineio==3.13.2
python-socketio==4.6.1
gunicorn --bind "0.0.0.0:${PORT:-8080}" --worker-class eventlet -w 1 run_app:app
client
<script src="//cdnjs.cloudflare.com/ajax/libs/socket.io/2.2.0/socket.io.js"
integrity="sha256-yr4fRk/GU1ehYJPAs8P4JlTgu0Hdsp4ZKrx8bDEDC3I="
crossorigin="anonymous">
@dachosen1 I'm sorry but this is really not possible. Can you show me the request URL that your client is sending to the server please?
@dachosen1 Well, I know you are going to disagree with me, but based on what I see the version of python-engineio that you are running in your server is not a 3.x version, and instead it is a 4.x. Check again, because the version that you reported above would not produce this error.
@miguelgrinberg ok ill try it again.
@mischa85 Once again the error message is correct. These errors are intended to stop you from doing things wrong. Why are you not monkey patching? It is required for Redis to work.
This error went away when downgrading eventlet. I opened an issue over there:
https://github.com/eventlet/eventlet/issues/678
Everything is now working on these versions:
[marcel@knaagbeest ~]$ pacman -Q python-engineio
python-engineio 4.0.0-1
[marcel@knaagbeest ~]$ pacman -Q python-socketio
python-socketio 5.0.3-1
[marcel@knaagbeest ~]$ pacman -Q python-flask-socketio
python-flask-socketio-git 5.0.0-1
Thank you for the great work @miguelgrinberg.
I have this issue as well, but it seems that I have the right versions. @miguelgrinberg
From pip freeze:
python-engineio==4.0.0
python-socketio==5.0.3
From npm:
vue-socket.io@3.0.5
engine.io-client@4.0.5
Looks exactly like the highlighted row from the documentation:
@mmajko What version of python-engineio do you have in your requirements.txt file? If you need to fix this, then uninstall python-socketio and python-engineio and then run the following:
pip install "python-socketio<5"
And this will give you a working set up that works for v2 clients. Then, save your requirements (including the versions of the dependencies), so that this does not happen to you again next time!
Thanks a million! @miguelgrinberg I am not familiar with web sockets and the likes but I needed to solve this problem in order to get an old web app to work on which my entire robotics project relies on. This was a huge boon for my project. Thanks again.
@torbenal: the table shows versions for the official JavaScript version of Socket.IO. You are using a different client. You need to find a mapping between your client and the reference JS client that I show in my version compatibility table.
@torbenal: the table shows versions for the official JavaScript version of Socket.IO. You are using a different client. You need to find a mapping between your client and the reference JS client that I show in my version compatibility table.
You're right, thank you. I figured out that vue-socket.io uses socket.io 2 so that's where the issue came from :)
@miguelgrinberg
Requirement already satisfied: Flask_SocketIO in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 13)) (5.0.0)
Requirement already satisfied: python-engineio in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 14)) (4.0.0)
Requirement already satisfied: python-socketio in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 15)) (5.0.3)
This is my current situation and it still throws the "the client is using an unsupported version of the SocketIO or EngineIO protocols
@sorensjf check your client.
I am not using this application with flask. I was building a server from scratch and i was getting the same error. For me it was resolved when i start using python 3.5 instead of 3.6.
Is this perhaps because the python-enginio changes depending which python version I'm using? if so, how can i use python 3.6 and keep python-enginio at version 4.0.0 ??
@DanielRomeo the version of Python does not matter, in fact I have dropped the support for 3.5 a while ago. What matters is your dependencies. If you don't pin every single dependency to a known version you are always open to risk of things breaking.
If you want to use python-engineio 4.x then you have to use python-socketio 5.x. And if you also use the JavaScript client, it has to be a 3.x release. You can't mix and match any versions as you like. The version compatibility chart in the docs tells you which versions work well together.
Im running SocketIO client and Flask-SocketIO. Had the same issue with incompatible versions which is now solved (by bumping socket.io-client version to 3.0.4 and Flask-socketio version to 5.0.1). Strange thing is prior to this being solved, I could execute API calls to Flask endpoints. After solving this problem, no API calls which require bearer token auth are going through.
Im running Flask/Flask-SocketIO --> uWSGI --> NGINX in a test environment with docker compose. SocketIO is connected to a Redis instance (for server emits)
Calls are being forwarded from NGINX to uWSGI via NGINX conf (partial conf):
location /api { uwsgi_pass appserver; include /etc/nginx/uwsgi_params; }
location /socket.io/ { proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; include uwsgi_params; uwsgi_pass unix:/var/www/racketlan/racketlan.sock; }
When the error occurs the following is printed out in uWSGI logs:
[ERROR] app: "401 Unauthorized: The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required."
The response to the web client is 504 Timeout.
NGINX outputs:
172.17.0.1 - - [05/Jan/2021:13:15:25 +0000] "GET /api/workflow HTTP/1.1" 504 569 "http://localhost:8000/app" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36" "-" nginx_1 | 2021/01/05 13:15:25 [error] 28#28: 12 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 172.17.0.1, server: , request: "GET /api/workflow HTTP/1.1", upstream: "uwsgi://unix:///var/www/**/.sock", host: "localhost:8000", referrer: "http://localhost:8000/app"
@calix so basically you are saying that upgrading your socket.io client from 2.x to 3.x broke your authentication? How is that possible, and how can this package have anything to do with it, since all you have changed is your Socket.IO client?
@calix so basically you are saying that upgrading your socket.io client from 2.x to 3.x broke your authentication? How is that possible, and how can this package have anything to do with it, since all you have changed is your Socket.IO client?
I don't think that step explicitly caused the issue. The previous issue was just masking another separate problem (not sure of the root cause, perhaps related to uWSGI). The other weird thing is, if I "reload" the singlepage react app, I get the static files and the javascript axios request succeeds. If I make the API call without reloading, the request timesout.
This is a very strange issue.
UPDATE The second issue was due to starting uwsgi with param "--callable". Removed this and all works fine (not sure why though).
Really recommend @miguelgrinberg's proposal to always pip freeze all dependencies. It will avoid a lot of headaches down the road.
On the client you can get the version to include in the script tags for the html page on the cdnjs.com web page: https://cdnjs.com/libraries/socket.io hope help somebody.
Perhaps I am misunderstanding the issue but it appears that something remains broken about the version dependencies. For example, if I use the client socket.io indicated at https://cdnjs.com/libraries/socket.io for 3.1.0 (https://cdnjs.cloudflare.com/ajax/libs/socket.io/3.1.0/socket.io.js) and connect that to a freshly pip instlalled flask_socketio instance running in a gevent flask server, and I enhance the python3.7/site-packages/engineio/server.py at line 350 to output the version in query['EIO'], what's output is 3 (instead of 4) ... and the version error message happens. Could the CDN socket.io for 3.1.0 be packaged incorrectly?
EDIT (to reflect @miguelgrinberg response below): I'll post over there when I get a chance but thought it was also relevant here because it calls into question the table in the docs and may explain some of the problem reports.
@aathan that is a question for the JS project, I do not know why the 3.x release would send EIO=3.
Requirement already satisfied: Flask_SocketIO in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 13)) (5.0.0) Requirement already satisfied: python-engineio in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 14)) (4.0.0) Requirement already satisfied: python-socketio in ./venv/lib/python3.9/site-packages (from -r requirements.txt (line 15)) (5.0.3)
This is my current situation and it still throws the "the client is using an unsupported version of the SocketIO or EngineIO protocols
pip install python-engineio==3.13.2 pip install python-socketio==4.6.1
let me know. do in your created environment only
I think I've found a solution as I've just had to deal with this issue. I believe it's due to our lovely miguelgrinberg also updating the python-engineio just make sure you pull 3.13.2 if your using say 4.6.1. Otherwise 4.0.0 python-engineio will be pulled which is causing incompatibility issues.
I have tried multiple versions of python socketio to connect my JavaScript socket.io-client but no luck. I have posted a question on stackoverflow please help. https://stackoverflow.com/questions/70948315/python-socketio-not-connecting-with-javascript-socket-io-client
python-socketio 5.6.0 python-engineio 4.3.2 Flask-SocketIO 5.1.2
These are the versions of packages that I had installed, still throws the above error. Please suggest patch
@RAAKASH upgrade your client. Also read all the comments above.
Thanks for your help
I use python flask as server frame React as front use socket.io-client 3.0.4 as client python-socketio 5.0.0 as server but l can not connect always "The client is using an unsupported version of the Socket.IO or Engine.IO protocols"
i want to konw why who can help me # #