Questions tagged [server-sent-events]

Server-Sent Events (SSE) are a a part of the HTML5 specification. SSE allows a uni-directional persistent connection between a client and server, such that the client makes only a single request and the server keeps pushing data to the client continuously, until the connection is closed.

Resources

1769 questions
27
votes
7 answers

Simple Way to Implement Server Sent Events in Node.js?

I've looked around and it seems as if all the ways to implement SSEs in Node.js are through more complex code, but it seems like there should be an easier way to send and receive SSEs. Are there any APIs or modules that make this simpler?
Jasch1
  • 525
  • 2
  • 8
  • 22
26
votes
2 answers

What is the difference between HTTP streaming and server sent events?

My understanding is that HTTP streaming involves the client sending an HTTP request and then response to the request being sent over time allowing the server to essentially push to the client. In what I have read it seems that SSEs operates along…
Bren
  • 3,516
  • 11
  • 41
  • 73
26
votes
3 answers

Python Flask, how to detect a SSE client disconnect from front end Javascript

Maybe this is a problem in Flask, there is no way to handle disconnection event on the server side. In Response class, there is a method named "call_on_close", where we can add a function without argument, e.g. on_close(), it will be fired when the…
bwlee
  • 333
  • 3
  • 10
25
votes
10 answers

While loops for server-sent events are causing page to freeze

I am currently working on a chat that uses Server-Sent Events to receive the messages. However, I am running into a problem. The server-sent event never connects and stays at pending because the page doesn't load. For example:
Shawn31313
  • 5,978
  • 4
  • 38
  • 80
25
votes
2 answers

Debugging HTML5 Server-Sent Events in-browser

Is there any way of viewing/debugging Server-Sent Events in Chrome (or perhaps Firefox)? I was hoping they'd appear in the Network tab of Chrome's developer tools. The closest way I know of is to drop down to Wireshark, but this is fairly…
Mike Chamberlain
  • 39,692
  • 27
  • 110
  • 158
24
votes
1 answer

Server-Sent Events connection timeout on Node.js via Nginx

I have a Node.js via Nginx setup and it involves Server-Sent Events. No matter what Nginx configuration I have, connection of sse is broken after 60 seconds and reinitialized again. It doesn't happen if I connect to application directly on port on…
Mariusz Nowak
  • 32,050
  • 5
  • 35
  • 37
23
votes
2 answers

Server-Sent Events costs at server side

If I understand the Server-Sent Events principle correctly, each time a client registers to an EventSource, it actually opens a new HTTP connection to the resource managing the event. Contrary to other HTTP requests, the connection stays alive so…
ouno
  • 233
  • 2
  • 4
22
votes
8 answers

Adding authorization header to Jersey SSE Client request

I am using Jersey client to connect to an SSE stream. The server requires that I add a header to the http request for authorization, but I can't figure out how to add the header. Here is my code: Client client =…
Quick
  • 343
  • 1
  • 3
  • 10
21
votes
2 answers

Is using HTML5 Server-sent-events (SSE) ReSTful?

I am not able to understand if HTML5s Server-sent-events really fit in a ReST architecture. I understand that NOT all aspects of HTML5/HTTP need to fit in a ReST architecture. But I would like to know from experts, which half of HTTP is SSE in (the…
2020
  • 2,821
  • 2
  • 23
  • 40
20
votes
3 answers

SSE(EventSource): why no more than 6 connections?

I wanted to see how many simultaneous SSE (aka EventSource) connections I could setup, before overloading my machine. But testing with Firefox (Firefox 18 or Firefox 20) it stopped at 6 connections: the additional connections give no error, but do…
Darren Cook
  • 27,837
  • 13
  • 117
  • 217
20
votes
2 answers

Downside of using Server-Sent events for bidirectional client-server communication (instead of WebSockets)

Recently I've found out of Server-Sent events as a much simpler alternative to WebSockets for doing push from the server. Most places that compare them (like here, here and here) say that if you don't need full duplex communications between client…
Facundo Olano
  • 2,492
  • 2
  • 26
  • 32
20
votes
4 answers

Is Comet obsolete now with Server-Sent Events and WebSocket?

or do Server-Sent Events and WebSocket replace Comet techniques?
orad
  • 15,272
  • 23
  • 77
  • 113
19
votes
3 answers

How can I make SSE with Python (Django)?

I have two different pages, one (A) that displays data taken from a model object, and one (B) that changes its fields. I would like that when the post data is sent from B to the server, the server changes the values in A. What is the best way to do…
Lorenzo Fiamingo
  • 3,251
  • 2
  • 17
  • 35
19
votes
3 answers

How does Server-Sent-Events work

I tried an SSE (Server-Sent-Events) using java on tomcat 8.0. Here are few things I noticed. I click a button that automatically makes a request to the servlet. Servlet's GET method gets executed which returns an event stream. Once the full stream…
John Eipe
  • 10,922
  • 24
  • 72
  • 114
19
votes
2 answers

SSE and Servlet 3.0

I have registered a typical SSE when page loads: Client: sseTest: function(){ var source = new EventSource('mySSE'); source.onopen = function(event){ console.log("eventsource opened!"); }; source.onmessage = function(event){ var data =…
nimo23
  • 5,170
  • 10
  • 46
  • 75