Since launching, Ably’s mission has been to deliver a best-in-class, interoperable realtime platform developers can trust for streaming data in apps, services, and APIs. We’ve always advocated for and supported open realtime protocols. As new protocols emerge we’re committed to supporting them on our platform so developers can do what they do best: build without worrying about infrastructure.
That’s why, as of today, anyone building on Ably can seamlessly stream data over the Server-Sent Events (SSE) protocol using the Ably Adapter.
No Ably Client Library SDK is needed thanks to the EventSource API (more on that below) - although we still recommend our realtime client library SDKs for most realtime use cases as they provide a richer set of features and reliability.
SSE becomes the fifth supported protocol for the Ably Adapter, with existing support for MQTT, STOMP, AMQP, and other proprietary realtime protocols. Note that this is a beta release but fully operational and production-ready.
What is SSE?
SSE is a server push technology enabling a browser or device to receive automatic updates from a server via HTTP connection. With SSE, servers initiate data transmission towards clients once an initial client connection has been established. While this is possible with a regular XHR Streaming request, SSE provides additional connection management and parsing logic on top.
SSE is commonly used to send message updates, new events, or continuous data streams to a browser client. It’s designed to enhance native, cross-browser streaming through a JavaScript API called EventSource. Using this API, a client can easily receive an event stream by sending a request to a particular URL endpoint. Hence no Ably Client Library SDK is needed.
If you want to jump right in, check out the:
Or feel free to contact us about how you can best use SSE and Ably.
Why are we supporting SSE and how is it helpful to you?
The nature of realtime messaging and streaming data mean different protocols serve different purposes better than others. For multiplexed, bidirectional streaming WebSockets, using one of Ably's Client Library SDKs, is perfect. For IoT devices with limited battery life, MQTT is more suitable.
As we continue to move toward a world of event-driven data streams and APIs, simply subscribing to a data stream and receiving events as they happen will become more widespread. Already many of our customers and realtime developers are seeking out simple, lightweight methods of streaming data when two-way interaction isn’t needed in the same connection.
Here’s a few scenarios where you might use SSE:
- Subscribing to a feed of cryptocurrency or stock prices
- Subscribing to a Twitter feed
- Receiving live sports scores
- News updates or alerts
In all of these examples it should take just a few lines of code and no additional dependencies, like full-blown SDKs, to subscribe to a stream of what is essentially new events being pushed from a server. SSE is rapidly being adopted by developers for use-cases just like this.
If you don’t want to use an Ably client library SDK on platforms that support SSE, and require simple subscribe-only streams, you might choose SSE because it’s an open standard, simple, and requires no SDKs on the client-side. HTTP Streaming may be considered on platforms without an SSE client. However, where possible, we strongly recommend the use of one of our Realtime client libraries, which provide more features and higher reliability, and the full use of our normal realtime messaging API.
In addition, with support for an open auth token scheme such as JWT, which Ably supports, SSE is able to provide auth with no client library. As a result, SSE is maturing fast and is now widely supported across browsers, platforms, and embedded IoT devices.
As such we feel SSE is at a stage of maturity and adoption where it’s time to support it at Ably as part of our Adapter function. The realtime industry is maturing but we’re yet to have clear standardization of protocols. Until then, Ably will continue to deliver on its commitment to supporting emerging realtime transport protocols in a fragmented ecosystem.
Get started with SSE and Ably
To get going with SSE, visit the Ably Adapter page, the SSE concept piece, the SSE docs, tutorials, and the 5-minute video overview. As always, feel free to contact us about how you can best use SSE and Ably for your data streaming needs.