-
-
Notifications
You must be signed in to change notification settings - Fork 891
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
Run error with uwsgi and gevent #381
Comments
The second exception only show when client disconnect like the browser redirect to the other page.It is look same with #377 The first exception show when client send a message to server,it cause the server throw a error and will cut down the connect before the client auto reconnect.But in my program only use a function which do nothing,so I think it's not my code cause this execption. |
After more test I found the second exception must show when client disconnect. But the first exception show random.Some time it works well,sometime it cause this error.And also some time after random times failed,it can work normal,than after a server reboot,it cause that error again. |
Please initialize SocketIO with additional logging, as follows:
Run the server and keep it running until it fails. Then please send me the complete log from the start to the point in which it failed. |
And
Are those info enough? |
You did not give me a complete session. Please give me the complete logs, from where you start the server, not just the section of the error. |
|
Thanks, I'm able to reproduce the problem now. I'll let you know once I figure out what's going on. |
Can I ask you to test your application with uwsgi 2.0.13.1? There are a couple of changes in 2.0.14 that cause some issues in the uwsgi integration code. I have to figure out exactly what changed and determine if the bug is theirs or mine. |
Please wait for me to rebuild uwsgi 2.0.13.1 on raspberrypi |
It has the same error with uwsgi 2.0.13.1
And
|
Any improvement if you upgrade to Flask-SocketIO 2.8.2? |
It seems OK.I will try more times to confirm this exception |
But the
|
Yes, I've seen this one too. It is benign, meaning that it does not interfere with the application. A similar error sometimes occurs with gunicorn as well. The problem comes from the fact that WebSocket does not fit well with the WSGI protocol. The error occurs when a standard WSGI response is issued when a WebSocket request ends. Web servers usually have a non-standard mechanism to indicate that the WSGI response should be omitted for those requests, but since that is done outside of the WSGI protocol and there are several different ways this was implemented by webservers, it tends to not work too well. I was thinking that maybe I should implement my own way to detect these cases, but I haven't done that yet, since the error can be ignored. |
I know that exception had no effect with normal use,only seem that not good,so I suggest can use a try-except to avoid display that. |
A try-catch exception in that place is not a good idea, because I really have no way to distinguish between an exception raised due to this issue, or by any other problems. If I do this, I risk masking other errors. Also, while uwsgi errors when start_response is called, gunicorn has a different manifestation of this issue, which causes an error that is internal to gunicorn, so I would have nothing to catch (see benoitc/gunicorn#1210 if you are curious about the details).
Hmm. I do not see this here. What I did is simply Ctrl-C the uwsgi process while a client was connected, then run it again. The client reconnected immediately and everything works fine. Are you doing anything different? |
I only use a emit() and set a flask session in server's connect().Does it will cause some exception only with uwsgi? |
@wwqgtxx does this happen when you use the example app in this repository? That's the app I tested this with. |
Sorry,I hadn't test the example app. |
I know that I call a init() function write by myself in connect().It cause connect() be so slow to cause this websocket connect timeout.I think the uwsgi may be has some time limit for a websocket parse time to cause this problem. |
@wwqgtxx yes, a slow connect handler can cause trouble, these are supposed to be quick. Consider that when the connect handler is invoked on the server, the client is already connected, but the server is not going to accept anything until the connect handler ends and accepts the connection. You may want to consider offloading this work that you are doing to an event that fires after the connection is fully established. |
So can we support app.before_first_request() or Flask-SocketIO provide a function can do same things for server init? |
The concept of requests does not exist in Socket.IO, so Flask's before_first_request does not really apply here. Besides, you don't want this function to be called only the first time, you want it called for every connection. The easiest way to implement what you need is to have the client send an event immediately after connecting. You can do what you need in the handler of the event. It's still not a good idea to make it a very long task, but at least it is not stopping the connection process. |
In fact I only need do a init() once,whatever the flask or flask-socketio do. |
I'm closing this, as the |
When I run my flask app with uwsgi and gevent,It always throw those exception
And
I'm only use the code like this
And start my program by
the uwsgi's start info is
If I run this code without uwsgi and set async_code to eventlet,every thing work well.
Please help me found the reason.
Thanks
The text was updated successfully, but these errors were encountered: