简体   繁体   中英

flask-SocketIO 5.X Error:400 “The client is using an unsupported version of the Socket.IO or Engine.IO protocols ”

It's my first time to use "flask-SocketIO" and I keep getting error 400 even while using the simplest code.

I'm trying to run the code locally on windows10

pip freeze:

WARNING: Could not generate requirement for distribution -rotli 1.0.9 (c:\python3\lib\site-packages): Parse error at "'-rotli=='": Expected W:(abcd...)
bidict==0.21.2
cffi==1.14.5
click==7.1.2
dnspython==1.16.0
eventlet==0.30.1
Flask==1.1.2
Flask-Login==0.5.0
Flask-SocketIO==5.0.1
Flask-SQLAlchemy==2.4.4
Flask-WTF==0.14.3
gevent==21.1.2
gevent-websocket==0.10.1
greenlet==1.0.0
gunicorn==20.0.4
itsdangerous==1.1.0
Jinja2==2.11.3
MarkupSafe==1.1.1
passlib==1.7.4
psycopg2==2.8.6
pycparser==2.20
python-dotenv==0.15.0
python-engineio==4.0.0
python-socketio==4.6.0
six==1.15.0
SQLAlchemy==1.3.23
tornado==6.1
Werkzeug==1.0.1
WTForms==2.3.3
zope.event==4.5.0
zope.interface==5.2.0

the command I used to run the script python test.py

Python code ( test.py ) - from socketIO's website.

from flask import Flask, render_template
from flask_socketio import SocketIO

app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret!'
socketio = SocketIO(app)

if __name__ == '__main__':
    socketio.run(app)

I've also tried a python link with html that has socket.io.min.js just to see if there would make any difference.

@app.route("/test", methods=['GET', 'POST'])
def test():

    return render_template("test.html")

test.html has this line before </body>

<script src="https://cdn.socket.io/3.1.1/socket.io.min.js"></script>

I've tried downgrading flask-socketIO to 4.x and use socketIO 2.x as front end but it didn't work either so I am guess the issue could be something else.

by Uninstall flask-socketio , python-socketio and python-engineio using those commands

pip uninstall flask-socketio
pip uninstall python-socketio
pip uninstall python-engineio

then reinstalling flask-socketio

pip install flask-socketio

I was able to resolve my issue, Apparently I had the wrong dependency and that is the best way to resolve it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM