Heroku sock=backend Server Request Interrupted for a Flask SocketIO application

我与影子孤独终老i 提交于 2019-12-23 10:51:29

问题


I have a flask-socketio app hosted on heroku with the following Procfile :

web: gunicorn --worker-class eventlet hello:app

Ever since I switched to socketio, the app has been behaving inconsistenly. Earlier the app would run for a while and then POST requests would start timing out.

Since yesterday night, I keep getting the error

sock=backend at=error code=H18 desc="Server Request Interrupted" method=GET path="/static/js/third-party/browser.js" host=deard.herokuapp.com request_id=725da6af-aa29-4293-a411-2c89977f1d4d fwd="216.165.95.0" dyno=web.1 connect=1ms service=36ms status=503 bytes=13811

I read the heroku error code description which says "The backend socket, belonging to your app’s web process was closed before the backend returned an HTTP response."

But I have no clue why this would be happening.

Any clue as to what I should be looking out for, will help me debug this.

I could share the code but its 300 lines long and since I don't know where the error is originating from, I am not sure if it would be helpful.


回答1:


This kind of "socket stream error" is raised by Flask when you cancel or resend the same request while on the server side (flask) you are still under computation in order to render layout corresponding to the initial request.

So it may be relative to timeout or network Error handling on both side (server/client).

Some question :

How long the request computation is during on server side ? How do you handle network error exception on server and client side ? Does exist any timeout on flask or client side ?

It is also possible that a new request is sent before the previous one is over..

Please share some code relative to request processing.



来源:https://stackoverflow.com/questions/34708144/heroku-sock-backend-server-request-interrupted-for-a-flask-socketio-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!