sysid / sse-starlette

BSD 3-Clause "New" or "Revised" License
505 stars 36 forks source link

Response does not stream to browser from localhost (Chrome or Firefox) #5

Closed bowmanjd closed 4 years ago

bowmanjd commented 4 years ago

I have used the exact example from the README. While it works fine from curl (each event shows .9 seconds apart), in the browser (Chrome or Firefox on Windows), it waits ~5 seconds, then shows the entire body once it has closed.

Have you seen this behavior? Is it an ASGI issue, or something with browsers? I have similar issues with many Python ASGI and SSE implementations. I hope I am just missing something obvious.

paxcodes commented 4 years ago

I didn't experience this issue when I was trying it out myself.

It sounds like an issue in the client code if it works fine from curl. Can you try using the code in example.py and see if that works?

bowmanjd commented 4 years ago

The example.py also has the same problem. No content is received until the connection is closed.

I did try a different computer, though, and that works fine. Perhaps this is a Windows issue, or particular to my machine? Firefox, Chrome, and Edge all have the same issue.

bowmanjd commented 4 years ago

Closing as it is clearly browser- or OS-related

paxcodes commented 4 years ago

SSE is expected to not work in older browsers. There are other known issues as well (see "Known Issues" tab in caniuse.com). Other than those, I can't think of anything else.

bowmanjd commented 4 years ago

Good point about the older browsers; however, I am using the latest versions of Chrome, Edge, and Firefox.

It turns out it had to do with Sophos Endpoint Security's "web protection" which was intentionally forcing buffering of the first two megabytes of an event stream. Troubling.

You can find my entire write up on StackOverflow.

I remain perplexed as to why non-Python implementations were working fine, and why ASGI does not expose and document some sort of flush method.

paxcodes commented 4 years ago

Wow. Thanks for sharing that. That's good to be aware of.

On Wed, Jun 10, 2020 at 3:23 AM Jonathan Bowman notifications@github.com wrote:

Good point about the older browsers; however, I am using the latest versions of Chrome, Edge, and Firefox.

It turns out it had to do with Sophos Endpoint Security's "web protection" which was intentionally forcing buffering of the first two megabytes of an event stream. Troubling.

You can find my entire write up on StackOverflow https://stackoverflow.com/questions/62129788/on-a-machine-running-sophos-why-do-all-my-browsers-fail-to-receive-server-sent .

I remain perplexed as to why non-Python implementations were working fine, and why ASGI does not expose and document some sort of flush method.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sysid/sse-starlette/issues/5#issuecomment-641908753, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADIDWNWZEJKYS4Z4YR2VYZDRV5NLZANCNFSM4NXD7RSA .

-- Rosalyn Margret “Pax” Williams