Skip to main content

Server Sent Events (SSE)

Server Sent Events

  1. 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.

  2. Successful Resource responses for SSE shall:

    1. Return the HTTP 200 status code.

    2. Have a Content-Type header set as "text/event-stream" or "text/event-stream;charset=utf-8".

  3. Unsuccessful Resource responses for SSE shall:

    1. Return an HTTP status code of 400 or greater.

    2. Have a Content-Type header set as "application/json" or "application/json;charset=utf-8".

    3. Contain a JSON object in the response body, as described in Error responses, which details the error or errors.

Server Sent Events - Listener

  1. ServerSent Event Listener will be listening on port 9090 and is started along with redfish server.

  2. This Listener will listen for GET requests from client on the ServerSentEventUri.

  3. 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

  1. User can Check for the serversent URI from the property "ServerSentEventUri" from the following URI.

    https://{{ip}}/redfish/v1/EventService


  2. User Issues a GET Request to the “ServerSentEventUri”.

    https://{{ip}}/redfish/v1/EventService/SSE
  3. 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".

  4. SSE client can be a curl or any browser supporting SSE as given in below link.

    https://en.wikipedia.org/wiki/Server-sent_events
  5. Now SSE client is continuously listening for SSE Events Subscribed for EventFormatType value given in the filter or Event as the default EventFormatType.

  6. 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.

  7. 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.CreateLimitReachedForResource


    Event 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 EventLog


    Event 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


  8. Whenever a SSE client closes the connection will stop streaming and the subscription related to the SSE client destination is deleted.

    Close SSE stream

    SSE Subscription gets deleted

  9. Similarly, whenever SSE subscription is deleted will close the respective SSE stream.

    Delete SSE Subscription

    SSE Stream get closed

  10. Whenever redfish-server stops/restart will close all connected SSE stream and all SSE related subscriptions is deleted.

    redfish-server restart

    All SSE streams get closed

    All SSE Subscriptions gets deleted

  11. Max SSE connection allowed 5, more than 5 SSE connections are not allowed.

Limitations

  1. 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).

  2. Last-Event-ID is not supported.

  3. At an interval of 2 minutes, SSE server will sent dummy comments to the clients to keep connection alive.