WebSocket transport not available. Install eventlet or gevent and gevent-websocket for improved performance

Viewed 20840

I am using socket io and flask application.Everthing works except I always get this message. This is my initialization:

app = Flask(__name__)
app.config['SECRET_KEY'] = APP_SECRET_KEY
jwt = JWTManager(app)
cors = CORS(app)
app.config['CORS_HEADERS'] = 'Content-Type'
# app.config['transports'] = 'websocket'
socketio = SocketIO(app, cors_allowed_origins="*", async_mode='threading')

socketio.run(app, debug=True)

What may cause this warning and what does it mean?

The console looks like this: enter image description here

  • tried already to install gevent and eventlet and it didn't remove the message
2 Answers

If it's the problem occurred when executing a python file Just try pip install eventlet its worked for me you can also try pip install gevent some times this can also do the trick!

Normally you do not include the async_mode option when you instantiate your server. By having async_mode='threading' you are forcing the server to ignore eventlet and/or gevent and go with the more basic server, which does not support WebSocket.

So remove async_mode, then install eventlet (or gevent and gevent-websocket). Now your server will have access to WebSocket and will not show the warning.

Related