Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How is SSE (Server-Sent Events) `retry` option supposed to work?

When sending SSE message from a server there is a parameter retry that can be put into a message. (https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events/Using_server-sent_events#fields).

The reconnection time to use when attempting to send the event. This must be an integer, specifying the reconnection time in milliseconds. If a non-integer value is specified, the field is ignored.

But I actually can not get what is it about. Can someone clarify what is this parameter for how it is supposed to work? I don't get what it is for and who (server or client?) is supposed to use it, and what for?

like image 645
WHITECOLOR Avatar asked Oct 29 '25 14:10

WHITECOLOR


1 Answers

It’s a client instruction: the browser will wait the specified time after it detects a broken connection (because the server closes the connection after a message perhaps) before re-establishing a connection to the SSE resource url.

like image 63
rburte Avatar answered Nov 01 '25 12:11

rburte



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!