WebSocket transport not available. Install simple-websocket for improved performance

Viewed 2316

Here is my full app code

from flask import Flask, render_template, request, session, redirect, url_for
from flask_socketio import SocketIO, join_room, send


app = Flask(__name__)
app.config['SECRET_KEY'] = 'secretjsidfjsidfjsdifjsdifj!'
socketio = SocketIO(app)


@app.route('/')
def index():
    return render_template('index.html')

@socketio.on('message')
def handle_message(msg):
    print('get message:'+ msg)
    send(msg, broadcast=True)


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

When I run the socketio server, it shows

skysea@qiuyuxuandeAir flask-test % python3 app.py
WebSocket transport not available. Install simple-websocket for improved performance.
 * Serving Flask app "app" (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
http://localhost:5000 is not an accepted origin. (further occurrences of this error will be logged with level INFO)
127.0.0.1 - - [28/May/2021 12:42:45] "GET /socket.io/?EIO=4&transport=polling&t=NcnI2J7 HTTP/1.1" 400 -

But I have installed simple-websocket

Here is my Flask-socketIO information

skysea@qiuyuxuandeAir flask-test % pip3 show flask_socketio 
Name: Flask-SocketIO
Version: 5.0.3
Summary: Socket.IO integration for Flask applications
Home-page: http://github.com/miguelgrinberg/Flask-SocketIO/
Author: Miguel Grinberg
Author-email: miguelgrinberg50@gmail.com
License: MIT
Location: /opt/homebrew/lib/python3.9/site-packages
Requires: python-socketio, Flask
Required-by: 

Here is my simple-websocket information

skysea@qiuyuxuandeAir flask-test % pip3 show simple-websocket
Name: simple-websocket
Version: 0.2.0
Summary: Simple WebSocket server and client for Python
Home-page: https://github.com/miguelgrinberg/simple-websocket
Author: Miguel Grinberg
Author-email: miguel.grinberg@gmail.com
License: UNKNOWN
Location: /opt/homebrew/lib/python3.9/site-packages
Requires: wsproto
Required-by: 

I use Mac M1, how can I fix this problem?

1 Answers

This happened to me as well, Installing gevent and gevent-websocket will wrap the websockets and run it.

Related