Hello, all!
I’m trying out Render and it’s not bad so far. Main reason I’m using it is because I’m trying to use Server-Side Events. Unfortunately, the connection hangs and doesn’t seem to send the data from the EventSource. It works in my local build, and it actually worked on here for a bit, but has since stopped.
Can anyone provide insight on this? Thanks.
Server-Sent Events definitely work for us on render.
Once a time connection errors (net::ERR_QUIC_PROTOCOL_ERROR 200 (OK)
) but event source reconnects just after this.
We worked with both native EventSource and @microsoft/fetch-event-source package.
Few tips:
-
Debug SSE endpoint with curl
-
Make sure that you are setting correct headers in response:
Connection: keep-alive
Content-Type: text/event-stream
Cache-Control: no-cache
-
Emit retry: 500
event when connection is opened
-
Try to emit ping event every 60 seconds or so to keep connection alive.
Let me know if this one helped
Thanks for the reply.
I think I know what the problem is: my machine is likely blocking the SSE connection. I tried it on other devices and they seem to work. I didn’t think this would be a problem.
Thanks for your help!
No problem.
I’d appreciate if you let me know whether Sever-Sent Events work on render.com without pings for long-lived connections.
I will try. They probably do. I’m not sure how long a Hobby server stays active for, though.
There’s no such thing as a Hobby Server. Limitations of Free tier instances can be seen at https://render.com/docs/free . All paid tiers continue to run as long as they’re paid for and not suspended.