flask-socketiopython-socketio

Server.emit() got an unexpected keyword argument 'broadcast' with Flask-SocketIO


Note: There is a discussion at GitHub but nothing was concluded.

I am getting error - "Server.emit() got an unexpected keyword argument 'broadcast'" after python update from 3.8 to 3.11 in the following code -

socketio.emit('message', response_data, broadcast=True, room=request.sid)

Following are the packages after python update -

Werkzeug~=3.0.3
Flask~=2.2.5
Flask-SocketIO~=5.3.6
python-engineio~=4.5.0
python-socketio~=5.8.0

Note: code was working fine with the previous packages-

Werkzeug~=2.0.3
Flask~=2.1.0
Flask-SocketIO~=4.3.2
python-engineio~=3.14.2
python-socketio~=4.6.1

Solution

  • It worked after downgrading the python-socketio and python-engineio.

    Following are the working combination of packages -

    Werkzeug~=3.0.3
    Flask~=2.2.5
    Flask-SocketIO~=5.3.6
    python-socketio~=5.7.2
    python-engineio~=4.7.0