# Server-Sent Events (SSE)

Server-Sent Events (SSE) is a protocol for sending real-time updates from a server to a client over a single HTTP connection. Your flows can both consume SSE streams (using `Http Fetch Streamed` and expose SSE endpoints to send events to connected clients (using various functions in the `Http Server-Sent Events` module).

## Consuming SSE Endpoints

<figure><img src="https://1896308808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdFpuRAnTVYgmlCXLLou%2Fuploads%2FVxCSOsIYPdLbreZhfJUV%2Fimage.png?alt=media&#x26;token=fbc9be07-47ec-4759-8805-127b166f829d" alt=""><figcaption></figcaption></figure>

An SSE stream can be consumed using [`Http Fetch Streamed`](https://docs.midio.com/midio-docs/built-in-nodes/http#fetchstreamed) to initiate a request, and then `Parse SSE Stream` to extract messages one at a time as they arrive. Notice that after handling each event, we loop back to the `Parse SSE Stream` function, which then lets us handle the next message. When the `stream closed` trigger fires, we don't loop back but just print a message to the log.

## Serving SSE Endpoints

<figure><img src="https://1896308808-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FRdFpuRAnTVYgmlCXLLou%2Fuploads%2FFqGFEpEXToHdey4REQle%2Fimage.png?alt=media&#x26;token=77192432-f774-4acb-975a-3aafd894cc73" alt=""><figcaption></figcaption></figure>

You can respond with an SSE stream from your own endpoints by first calling `Start SSE Response`, and then call `Send SSE Event` as many times as you like with the data you want to transmit. The example above sends each word in the string one at a time.
