Jump to content

Server-sent events: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
m pull out full stop
No edit summary
Line 1: Line 1:
'''Server-Sent Events''' ('''SSE''') is a [[server push]] technology enabling a client to receive automatic updates from a server via an HTTP connection, and describes 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. The EventSource API is standardized as part of [[HTML5]]<ref>{{Cite web |date=31 March 2022 |title=HTML Living Standard: 9.2 Server-sent events |url=https://html.spec.whatwg.org/multipage/server-sent-events.html |publisher=[[WHATWG]]}}</ref> by the [[World Wide Web Consortium|WHATWG]]. The [[Media type|mime type]] for SSE is <code>text/event-stream</code>.{{TOCright}}
{{TOCright}}
'''Server-Sent Events''' ('''SSE''') is a [[server push]] technology enabling a client to receive automatic updates from a server via an HTTP connection, and describes 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. The Server-Sent Events EventSource API is standardized as part of [[HTML5]]<ref>{{Cite web |date=31 March 2022 |title=Server-Sent Events |url=https://html.spec.whatwg.org/multipage/server-sent-events.html |publisher=W3C}}</ref> by the [[World Wide Web Consortium|W3C]]. The mimetype for SSE is <code>text/event-stream</code>.

== History ==
== History ==
The [[WHATWG]] Web Applications 1.0 proposal<ref>{{cite web|url=http://www.whatwg.org/specs/web-apps/current-work/#server-sent-events|title=Web Applications 1.0 specification}}</ref> 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".<ref>{{cite web|url=http://dev.opera.com/blog/event-streaming-to-web-browsers/|title=Event Streaming to Web Browsers}}</ref><ref name="tutorial">[http://www.html5rocks.com/en/tutorials/eventsource/basics/ Stream Updates with Server-Sent Events, Eric Bidelman, HTML5Rocks website.]</ref>
The SSE mechanism was first specified by [[Ian Hickson]] as part of the "[[WHATWG]] Web Applications 1.0" proposal starting in 2004.<ref>{{cite web |date=2006-09-01 |title=Web Applications 1.0 specification |url=http://www.whatwg.org/specs/web-apps/current-work/#scs-server-sent |url-status=unfit |archive-url=https://web.archive.org/web/20060901014818/http://www.whatwg.org/specs/web-apps/current-work/#scs-server-sent |archive-date=2006-09-01 |access-date=2006-09-01 |website=WHATWG}}</ref> In September 2006, the [[Opera (web browser)|Opera web browser]] implemented the experimental technology in a feature called "Server-Sent Events".<ref>{{cite web |last=Bersvendsen |first=Arve |date=1 September 2006 |title=Event Streaming to Web Browsers |url=http://dev.opera.com/blog/event-streaming-to-web-browsers/ |website=[[Opera (company)|dev.opera.com]]}}</ref><ref name="tutorial">[http://www.html5rocks.com/en/tutorials/eventsource/basics/ Stream Updates with Server-Sent Events, Eric Bidelman, HTML5Rocks website.]</ref>


== Browser support ==
== Browser support ==

Revision as of 22:59, 30 May 2022

Server-Sent Events (SSE) is a server push technology enabling a client to receive automatic updates from a server via an HTTP connection, and describes 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. The EventSource API is standardized as part of HTML5[1] by the WHATWG. The mime type for SSE is text/event-stream.

History

The SSE mechanism was first specified by Ian Hickson as part of the "WHATWG Web Applications 1.0" proposal starting in 2004.[2] In September 2006, the Opera web browser implemented the experimental technology in a feature called "Server-Sent Events".[3][4]

Browser support

All modern browsers support server-sent events: Firefox 6+, Google Chrome 6+, Opera 11.5+, Safari 5+, Microsoft 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).

Erlang

  • Lasse EventSource server handler for Erlang's cowboy
  • Shotgun EventSource client in Erlang

Go

  • eventsource EventSource library for Go.
  • go-sse SSE implementation for Go.
  • sse SSE with optimized decoder for Go
  • gosse Server-sided implementation with channel concept and further features for out-of-the-box use.

Java

  • Javalin - lightweight Java and Kotlin web framework
  • 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
  • SSE Client SSE Client library

Node.js

Objective C

  • TRVSEventSource - EventSource implementation in Objective-C for iOS and macOS using NSURLSession.

Perl

PHP

Python

Ruby

  • Faye - Simple pub/sub messaging for the web.

Rust

  • Warp A web server framework.

Scala

Swift

  • EventSource - EventSource implementation using NSURLSession.

See also

References

  1. ^ "HTML Living Standard: 9.2 Server-sent events". WHATWG. 31 March 2022.
  2. ^ "Web Applications 1.0 specification". WHATWG. 2006-09-01. Archived from the original on 2006-09-01. Retrieved 2006-09-01.{{cite web}}: CS1 maint: unfit URL (link)
  3. ^ Bersvendsen, Arve (1 September 2006). "Event Streaming to Web Browsers". dev.opera.com.
  4. ^ Stream Updates with Server-Sent Events, Eric Bidelman, HTML5Rocks website.
  5. ^ When can I use... Server-sent DOM events

External links