The SSE Proxy component provides 3 server actions: SSE_Init, SSE_SendEvent, and SSE_Request.
SSE_Init
The SSE_Init action initializes the OutSystems Exposed REST API response as a SSE stream, enabling the server to send events to the client. This action sets the appropriate HTTP headers (Content-Type: text/event-stream) to support Server-Sent Events (SSE), keeping the connection open for continuous event transmission.
Content-Type: text/event-stream
This action should be called at the beginning of an exposed REST API to establish the SSE stream for sending events. Once initialized, you can use the SSE_SendEvent action to push events to the client.
SSE_SendEvent
Call SSE_Init to start the SSE stream.
Use SSE_SendEvent to send events as needed during the lifecycle of the API response.
The SSE_SendEvent action allows you to send an event to the client over an active SSE stream. This action is used to push real-time updates to the client during an active session. The event can contain any relevant data, such as notifications, messages, or updates from the server.
Event (Record - Required)The event to be sent to the client. This is a record containing two fields: the event type and the event data.
Event
ClientDisconnected (Boolean)This value indicates whether the client has disconnected from the server. If True, the Event was not sent to the client.
ClientDisconnected
This action should be called to push events to clients after the SSE stream is initialized with SSE_Init. You can send events as needed, passing the necessary event data through the Event parameter.
Initialize the SSE stream using SSE_Init.
Use SSE_SendEvent to send custom events to the client.
SSE_Request
The SSE_Request action allows you to execute a request to an external API that implements Server-Sent Events (SSE). The response from the external API (in the form of events) is returned as a list and can also be forwarded to the OutSystems REST API Response. If the external API does not respond with a HTTP Status Code 200 and the appropriate Content-Type (text/event-stream), an exception will be thrown.
text/event-stream
Forwarding events is particularly useful in scenarios where the external API request requires authentication (e.g., using API keys, tokens, etc.), and you do not want to expose sensitive credentials in the client-side request. By forwarding events, you can keep these authentication details secure on the server side.
Note: If you intend to forward the events to the OutSystems REST API Response, SSE_Init must be called first to initialize the response as a stream.
HttpMethod (Text - Required)The HTTP verb (GET, POST, etc.) used to access the API.
HttpMethod
GET
POST
URL (Text - Required)The URL of the API implementing Server-Sent Events.
URL
Headers (Record List - Optional)A list of headers to send with the request. Useful for providing authentication tokens or other required headers.
Headers
Body (Text - Optional)The content to be sent in the body of the request. Used if the API requires a payload.
Body
BodyMediaType (Text - Optional)The media type for the request body (e.g., application/json for JSON data).
BodyMediaType
application/json
ForwardEventsToRestApiResponse (Boolean - Optional)If set to True, events received in the API response will be forwarded to the OutSystems REST API response stream.
ForwardEventsToRestApiResponse
True
ClientDisconnected (Boolean)This value indicates whether the client has disconnected from the server. If True, the request stops listening for events. The list of Events returned in the output parameter only contains Events that were received until the client disconnected.
Events (Record List)A list of events received in the API response. This contains the stream of events returned by the external SSE API.
Events
Use this action to execute a request to an external SSE-enabled API. You can process the events returned (after the stream ends) and/or forward them (in real-time) to an OutSystems REST API response for direct communication with the client. If you choose to forward the events, make sure to call SSE_Init first to initialize the response as a SSE stream.
Call SSE_Init to initialize the OutSystems REST API response as a SSE stream.
Set the SSE_Request inputs with the appropriate HTTP method, URL, headers, and request body if necessary.
Set ForwardEventsToRestApiResponse to True to forward the events to the OutSystems API response.
Call the SSE_Request action to receive events from the external SSE API.
Debug/Troubleshooting
All actions in the SSE Proxy component have an input parameter called DebugLogsEnabled (Boolean - Optional). If set to True, debug logs will be registered in the Service Center general logs with the source "SSEProxy". This can help you troubleshoot issues and monitor the event stream in real-time.
DebugLogsEnabled
WARNING: Avoid using this option in a production environment, as it can generate a large amount of logs and potentially affect system performance.