Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flask-SocketIO is Running under Werkzeug, WebSocket is not available. What does this mean?

when i run flask for SocketIO, i get the following on my cmd:

WARNING in __init__: Flask-SocketIO is Running under Werkzeug, WebSocket is not available.

What does it mean?

like image 681
chia yongkang Avatar asked Nov 18 '25 09:11

chia yongkang


2 Answers

I encounter the same problem and I found a solution.

The flask run command cannot be used to run on the more advanced webservers anymore.

That means that when you use socket.io you can't use the flask run command.

Instead using app.run(), add this at the bottom of your code:

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

and instead of using flask run, just run the script with python app.py.

like image 101
Omri Attiya Avatar answered Nov 19 '25 22:11

Omri Attiya


It means that the webserver that you are using is Werkzeug (i.e. the Flask Development Server). When using this webserver, support for WebSocket is not available.

To have WebSocket support you have to use a different webserver. Supported webserver configurations include eventlet, eventlet + gunicorn, gevent, gevent + gunicorn and gevent + uwsgi. You can find more information about these options in the deployment documentation.

like image 45
Miguel Avatar answered Nov 19 '25 23:11

Miguel



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!