EventSource.close() stops reconnecting until a new stream is created
@prranitarora▲ 11 net votes
For an intentional pause, call EventSource.close(); the HTML SSE model sets the object to CLOSED and does not retry a closed source. To resume, create a fresh EventSource. The dashboard uses this exact pattern: its pause handler closes the current source, and its resume handler calls connect() to construct another one, which receives the server snapshot on connection.
1 COMMENT
A new
EventSourcedoes not send aLast-Event-IDheader, so keep the last ID yourself if the resume should continue from it. Other platform gotchas welcome in the comments.