Flask/Python socketio Modules Compatibility with Flask-SocketIO 5.3.6 and Socket.IO 4.7.4

68 Views Asked by At

I have a very basic Flask Socket-IO project setup:

from flask import Flask, render_template
from flask_socketio import SocketIO, emit

app: Flask = Flask(__name__)
app.config['SECRET_KEY'] = 'top-secret'
app.debug = True  # for development

socketio: SocketIO = SocketIO(app, cors_allowed_origins='*')


@app.route('/join', methods=['GET'])
def join():
    return render_template('index.html')


@socketio.on('connect')
def connect():
    # TODO: implement connection logic
    emit('after connect',  {'data': 'connected'})


@socketio.on('disconnect')
def disconnect():
    # TODO: implement disconnection logic
    pass


if __name__ == '__main__':
    socketio.run(app, port='8000', allow_unsafe_werkzeug=True)

When I run it, I get this error message:

The client is using an unsupported version of the Socket.IO or Engine.IO protocols

I've read this post and understand this as a compatibility issue between client and server Socket.IO versions.

However, I'm essentially using all the latest versions of the dependencies, which also by the book and the other book is supposed to work. I don't know which dependency should I downgrade, and how much should I downgrade it.

My current versions on server:

Flask-SocketIO     5.3.6
python-engineio    4.9.0
python-socketio    5.11.1

I'm using https://cdn.socket.io/4.7.4/socket.io.min.js in my index.html, so I'd assume I'm using 4.7.4 for client version.

Since it's a fresh project, I'm trying to use the newest versions of the dependencies. Does anyone know what would be the minimum (or close to minimum) downgrade required to get this working?

0

There are 0 best solutions below