flask-uwsgi-websocket icon indicating copy to clipboard operation
flask-uwsgi-websocket copied to clipboard

ws connection failed

Open hbo-lambda opened this issue 4 years ago • 4 comments

I don't know the reason why the connection failed

chrome:

shell:

code:

from flask import Flask, render_template
from flask_uwsgi_websocket import WebSocket

app = Flask(__name__)
ws = WebSocket(app)


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


@ws.route('/websocket')
def echo(ws):
    while True:
        msg = ws.receive()
        if msg is not None:
            ws.send(msg)
        else:
            return


if __name__ == '__main__':
    app.run(debug=True, threads=16, port=8080)

hbo-lambda avatar Jun 08 '21 09:06 hbo-lambda

+1, same problem with 0.6.1

hnmzzzxxl avatar Nov 29 '21 09:11 hnmzzzxxl

+1 with 0.5.3 on Py3

ptallada avatar Dec 28 '21 10:12 ptallada

Same here unfortunately

JortdeBokx avatar Apr 06 '22 15:04 JortdeBokx

i fix this problem,this is mainly the high verison flask need a high version werkzeug. But the high version werkzeug added a judgment on whether the request is websocket。so the add_url_rule need change: old: rule = Rule(rule, methods=methods, **options) new: rule = Rule(rule, methods=methods, websocket=True, **options)

Rmond avatar May 26 '22 00:05 Rmond