Server Sent Events (SSE)
Server Sent Events
Server-Sent Events (SSE), as defined by the Web Hypertext Application Technology Working Group, allows for a client to open a connection with a web service, and the web service can continuously push data to the client as needed.
Successful Resource responses for SSE shall:
Return the HTTP 200 status code.
Have a Content-Type header set as "text/event-stream" or "text/event-stream;charset=utf-8".
Unsuccessful Resource responses for SSE shall:
Return an HTTP status code of 400 or greater.
Have a Content-Type header set as "application/json" or "application/json;charset=utf-8".
Contain a JSON object in the response body, as described in Error responses, which details the error or errors.
Server Sent Events - Listener
ServerSent Event Listener will be listening on port 9090 and is started along with redfish server.
This Listener will listen for GET requests from client on the ServerSentEventUri.
ServerSentEventUri is a property under EventService Resource that contains the URI to which client should give a GET request to indicate that the server should send the events in the form of SSE by opening a connection with the client and to use this connection to end subsequent events as a stream with "text/eventstream" Content-Type header.
Server Sent Events - Workflow
User can Check for the serversent URI from the property "ServerSentEventUri" from the following URI.
https://{{ip}}/redfish/v1/EventService
User Issues a GET Request to the “ServerSentEventUri”.
https://{{ip}}/redfish/v1/EventService/SSE
The above requested is redirected from lighttpd to the serversent event listener which validates the request URI along with the given filter parameters if any and creates a subscription for successful validation in the following URI.
https://{{ip}}/redfish/v1/EventService/Subscriptions
SSE Server also sends a HTTP Response with 200 Status Code along with Content-Type Header as "text/event-stream".
SSE client can be a curl or any browser supporting SSE as given in below link.
https://en.wikipedia.org/wiki/Server-sent_events
- Now SSE client is continuously listening for SSE Events Subscribed for EventFormatType value given in the filter or Event as the default EventFormatType.
- Whenever an event is triggered in Redfish, events are filtered according to the filter parameters as provided in the Event Subscription and is sent to the SSE Server. SSE Server sends the events as stream data to the SSE Event destinations.
- Events gets filter by filter property values.
Table 1. SSE Supported / Non-Supported Filter Properties SSE Supported Filter properties
SSE Not Supported Filter properties:
EventFormatType
MetricReportDefinition
MessageId
SuboridinateResources
OriginResource RegistryPrefix
ResourceType Event Format Type - Event
When user creates an SSE Event Destination with EventFormatType as Event, then SSE client will get an Event in Event format.
https://{BMC_IP}/redfish/v1/EventService/SSE?$filter=EventFormatType eq Event
Event Format Type - MetricReport
When user creates an SSE Event Destination with EventFormatType as MetricReport, then SSE client will get an Event in MetricReport format.
https://{BMC_IP}/redfish/v1/EventService/SSE?$filter=EventFormatType eq MetricReport
Event Format Type - MessageId
https://{{ip}}/redfish/v1/Registries/{{Registry_instance.json}
When User creates an SSE Event Destination with supported MessageId in Registries then SSE client will get an event only if MessageId are matches with the generated event MessageId.
https://{BMC_IP}/redfish/v1/EventService/SSE?$filter=MessageId eq EventLog.1.0.ResourceAdded
or MessageId eq Base.1.5.CreateLimitReachedForResourceEvent Format Type - OriginResource
When User creates an SSE Event Destination with OriginResource then SSE client will get an event only if OriginResource are matches with the generated event Orgin of Condition.
https://{BMC_IP}/redfish/v1/EventService/SSE?$filter=OriginResource eq /redfish/v1/AccountService/Accounts
Event Format Type - RegistryPrefix
https://{{ip}}/redfish/v1/EventService
When User creates an SSE Event Destination with supported RegistryPrefixes, then SSE client will get an event only if RegistryPrefixes are matches with the generated event MessageId.https://{BMC_IP}/redfish/v1/EventService/SSE?$filter=
RegistryPrefix eq Base or RegistryPrefix eq Security or RegistryPrefix eq EventLogEvent Format Type - ResourceType
https://{{ip}}/redfish/v1/EventService
When User creates an SSE Event Destination with supported ResouceTypes in EventService, client will get an event only if ResourceTypes are matches with the generated event OriginOfCondition.https://{BMC_IP}/redfish/v1/EventService/SSE?$filter=ResourceType eq AccountService or ResourceType eq Chassis
Whenever a SSE client closes the connection will stop streaming and the subscription related to the SSE client destination is deleted.
Close SSE streamSSE Subscription gets deletedSimilarly, whenever SSE subscription is deleted will close the respective SSE stream.
Delete SSE SubscriptionSSE Stream get closedWhenever redfish-server stops/restart will close all connected SSE stream and all SSE related subscriptions is deleted.
redfish-server restartAll SSE streams get closedAll SSE Subscriptions gets deleted- Max SSE connection allowed 5, more than 5 SSE connections are not allowed.
Limitations
Closing SSE Client Connection will have a delay of 2 minutes to get updated in the event subscription collection. (Step 8 in workflow of ServerSentEvents).
Last-Event-ID is not supported.
At an interval of 2 minutes, SSE server will sent dummy comments to the clients to keep connection alive.