Server-sent events
Server-Sent Events (SSE) is a server push technology enabling a client to receive automatic updates from a server via HTTP connection. The Server-Sent Events EventSource API is standardized as part of HTML5[1] by the W3C.
History
The WHATWG Web Applications 1.0 proposal[2] included a mechanism to push content to the client. On September 1, 2006, the Opera web browser implemented this new experimental technology in a feature called "Server-Sent Events".[3][4]
Overview
Server-Sent Events is a standard describing how servers can initiate data transmission towards clients once an initial client connection has been established. They are commonly used to send message updates or continuous data streams to a browser client and designed to enhance native, cross-browser streaming through a JavaScript API called EventSource, through which a client requests a particular URL in order to receive an event stream.
Web browsers
Browser | Supported | Notes |
---|---|---|
Internet Explorer | No | [5] |
Mozilla Firefox | Yes | Starting with Firefox 6 [5] |
Google Chrome | Yes | Starting with Chrome 6 [5] |
Opera | Yes | Starting with Opera 11.5 [5] |
Safari | Yes | Starting with Safari 5.0 [5] |
Microsoft Edge | Yes | Starting with Edge 79 [5] |
Libraries
.NET
- Service Stack EventSource library with both server and client implementations.
ASP.NET
- SignalR - Transparent implementation for ASP.NET.
C
- HaSSEs Asynchronous server-side SSE daemon written in C (It uses one thread for all connected clients).
Go
- eventsource EventSource library for Go.
- go-sse SSE implementation for Go.
- go-rfc/sse Optimised SSE decoder for Go
Java
- jEaSSE - Server-side asynchronous implementation for Java servlets and Vert.x
- Akka HTTP has SSE support since version 10.0.8
- alpakka Event Source Connector EventSource library for alpakka which supports reconnection
- Spring WebFlux Server and client side Java implementation built on reactive streams and non-blocking servers
- Jersey has a full implementation of JAX-RS support for Server Sent Events as defined in JSR-370
- Micronaut HTTP server supports emitting Server Sent Events
- JeSSE - Server-side library with user/session management, group broadcast, and authentication
- Armeria has server and client-side asynchronous SSE implementation built on top of Netty and Reactive Streams
- Play Framework Event Source for server-sent event emission
Node.js
- sse-stream - Node.js/Browserify implementation (client and server).
- total.js - web application framework for Node.js - example + supports WebSockets (RFC 6455)
- eventsource-node - EventSource client for Node.js
- Thread-SSE - A library for Node.js and web browser to develop security and high-performance SSE.
Objective C
- TRVSEventSource - EventSource implementation in Objective-C for iOS and macOS using NSURLSession.
Perl
- Mojolicious - Perl real-time web framework.
PHP
- Hoa\Eventsource - Server implementation.
Python
- Python SSE Client - EventSource client library for Python using Requests library.
- Server Side Events (SSE) client for Python - EventSource client library for Python using Requests or urllib3 library.
- django-eventstream - Server-Sent Events for Django.
- flask-sse - A simple Flask extension powered by Redis.
- sse
- event-source-library - Implementation in python2 with Tornado. Client and server implementations.
Ruby
- Faye - Simple pub/sub messaging for the web.
Rust
- Warp A super-easy, composable, web server framework for warp speeds.
Scala
- Akka HTTP has SSE support since version 10.0.8
- alpakka Event Source Connector EventSource library for alpakka which supports reconnection
Swift
- EventSource - EventSource implementation using NSURLSession
References
External links
- Server-Sent Events. W3C Recommendation.
- HTML5 Server-push Technologies, Part 1. Introduction into HTML5 Server-push Technologies. Part 1 covers ServerSent Events.
- Using Server-Sent Events. A concise example of how to use server-sent events, on the Mozilla Developer Network.
- EventSource reference on MDN
- Django push: Using Server-Sent Events and WebSocket with Django Django push: Using Server-Sent Events and WebSocket with Django.
- Server-Sent Events Example in Spring
- Server-Sent Events vs WebSockets