问题
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