3

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?

chia yongkang
  • 786
  • 10
  • 20

2 Answers2

5

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.

Omri Attiya
  • 3,917
  • 3
  • 19
  • 35
2

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.

Miguel Grinberg
  • 65,299
  • 14
  • 133
  • 152