
The client needs a listener to process messages sent by the server. Therefore it's possible for the server to resume processing an incoming request without having to start from the beginning. The id part is useful when the client retries to connect to the server, it will include Last-Event-ID in the header. You can send a message cotaining multiple lines separated by \n. The end of a message is indicated by double endline \n\n. response.write(retry: 10000) // Retry in 10 secondsĮvery message should have id and data. In order to do so, you have to send a message with the following format before sending any data. If something cause the connection error, you can tell the browser to retry. Unfortunately not all browsers support SSE, as listed on the table below Browser

The client doesn't need to perform pooling or send any requests to get the update message. It's the responsibility of the server to keep the client get the progress. With SSE, the server can tell the progress to the client by sending a sequence of messages. On the other side, the client needs to know the progress of that long process. For example, your server takes a long time for processing something (maybe for a few minutes or even hours).

It makes use of JavaScript's Event Source API.

SSE is usually used in a condition where you need to send continuous stream or data message updates to client. Server-Sent Events (SSE) is a technology in which the server sends update to the client (usually a web browser) automatically. The standard of how the server should send data to the client has been standarized as a part of HTML5.
NODE JIRA CLIENT RETRY HOW TO
Do you need to impleent Server-Sent Events in Node.js? In this post, I'll explain how it works and how to implement it using Node.js back-end and JavaSript front-end.
