SSE connections timeout each 5 minutes
I have deployed a flask sse based app into railway using a dockerfile and gevent. When I check the Networking tab on the inspection window in my browser I see the connection restarting each 5 minutes which is not the case when I was developping my app locally. This issue leads after some days of redeploying the app to have a stream timeout error and stop giving any sse connection until snapshot restarted.
32 Replies
Project ID:
87705bfd-1f41-4d43-8e4d-ed1380fbc20e
87705bfd-1f41-4d43-8e4d-ed1380fbc20e
is this a post request?
it's an event stream
tell me the request method please
it's like a websocket
tell me the request method please
okey sorry
it's a get request to the sse endpoint which makes the connection with the server and keeps it alive until the client aborts
it's a get requestthank you
I was just confused if you were familiar with the topic. This is my fault sorry
I didn't answer you first straight forwardly
i am familiar
in any case I should have answered directly
dont worry about it
so far, i have been able to hold a sse connection open done with a get request, time is sitting at 6 minutes
you can try it for yourself
https://utilities.up.railway.app/sse
locally?
okey
it sends a timestamp every second
it may not follow EventStream spec, but it is still sse
this is the part of my code responsible for sse. Is there anything here that maybe causing the connection restarting when hosted in railway?
maybe this if "text/event-stream" not in request.accept_mimetypes:
abort(400)?
id have to guess it would more so be with your gunicorn and gevent setup
yeah that's highly probably since I didn't use it in the dev process.
"gunicorn -b 0.0.0.0:8000 main:app --worker-class gevent" this is my startup command
can you show me the headers tab of this?
is that all of the response headers?
yes
show me the same screenshot but to the server running locally
ok one minute
connection: close
send
Connection: Keep-Alive
instead, the demo app sends keep alive
dont know if thats your issue but worth a shothahahaha
interesting, fix that and then try it out on railway
I added it to my github repo and redeployed the app but the connection keep-alive was not added
was the connection still closed after 5 minutes
Yes the same issue persists
well keep playing around, im sure youll get it