-
Notifications
You must be signed in to change notification settings - Fork 37
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
Frozen Client Connections - SSE Send Timeout #89
Comments
Possible SolutionMy only idea so far is to detect a long send call. Ideally, I would like to do this outside the main...blodow:sse-starlette:feat/add_send_timeout The return statement in the server code would then read: return EventSourceResponse(_event_generator(), send_timeout=1) # very short for demonstration Example output:
If that is acceptable, I can create a PR for it. If there are better ideas on how to do this, esp. from outside the library, I'm all ears. |
First off, thanks @sysid for this library!
The Problem
I have been running into a situation whereby the HTTP connection from a certain client was kept open, but the client -- through an unrelated bug -- stopped reading from the connection. This led to a problem where the SSE event generator, unaware of this issue of suspended reading, continued generating chunks to send on this connection, slowly saturating TCP buffers before finally simply hanging in the send call.
I would like my server app to be able to protect itself from this DOS-like attack vector by recognizing a live, stale client connection.
Example
An easy way to replicate the issue is e.g. a
curl
process that is suspended to the background withCtrl+Z
:A minimal server example:
example output:
The text was updated successfully, but these errors were encountered: