-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ConnectionError() / Invalid frame header when using debug #70
Comments
It has been challenging to get Flask and Werkzeug to work, I have fixed several issues that triggered errors during disconnection, but somehow I have missed this one. I don't know if I'll be able to make it work without breaking other use cases. |
Yeah I think it's fine if it can't be fixed, it's not something that breaks much to be honest, it doesn't seem to cause any crash or anything (although I don't know if behind the scenes it leaves some weird state that could break things later). But it's good to have it documented so others stumbling into it know that it's happening because the debug flag. |
I have the same issue as well, but no error in the browser. And dispite this, the ws is working.
My code for ws is looking for an incoming connection and depending on some state variable decide to close access or to continue and use the ws channel. |
@gbrault I'm not sure what made you think your issue is the same as the one reported here. I really do not see anything in common. Please write a new issue and include code to help me reproduce the issue. |
What browser are you using for testing? I was just debugging similar issue and it turns out that Chromium-based browsers would just silently close unsecured localhost WebSockets connection. It worked fine when I tried Safari on macOS. |
Are you asking me? I think the reproduction steps make it clear that this is not the browser closing the connection automatically, but the server throwing an error when I try to close the connection manually from the browser, but if there is something unclear please let me know so I can improve the bug description. |
All the browser I used got the same result: Firefox, Chrome and Edge. |
@gbrault I think saying this is a Linux vs Windows problem is a mistake. You have different versions of Flask and Werkzeug on your Linux and Windows machines and that explains the different behaviors. This problem occurs because Werkzeug (Flask's development web server) is not designed to manage a WebSocket connection. I have attempted to install some hacks that prevent the error during disconnection, and this appears to work on some versions, but not on others. At the end of the day, Werkzeug is a development web server, so I do not consider this a critical issue. For your production deployment you wouldn't be using this web server, so this error is something that you only need to put up with while developing. |
@ror3d would you like to install the main branch of this repo and confirm that you are not getting any more crashes when a client closes the WebSocket? The exit should now be clean for both debug and non-debug. Note that I have only tested Flask 3.0 and Werkzeug 3.0. |
@miguelgrinberg Hi! I can confirm that the connection error no longer appears in the terminal on the server side, although Chrome still reports a Thanks for your work! |
I am trying this extension and I am getting an error when running the flask app with the debug webserver.
A minimum example is:
If I run the app like
flask --app app run --debug
, and connect to it from the browser with something likeIt will send the data every 2 seconds as expected, but once I call
on the browser, the server will raise a
ConnectionError
with the trace:and the browser will get an error like:
This does not happen when running the server without the
--debug
option.The text was updated successfully, but these errors were encountered: