server-sent-events

Grails Server Sent Event

十年热恋 提交于 2019-12-23 21:45:48
问题 I need to get Server-sent-events working with Grails. I feel like I am close, but just not quite there. The JavaScript request successfully reaches the controller, but it throws an error every time. It keeps retrying once every 2 seconds or so (probably due to the error). I need to send an event to the user when the server's session timer gets below 5 minutes. I am trying to use HTML5's EventSource because I only want to send a single request to the server (multiple requests will reset the

Firefox doesn't restore server-sent events connection

我们两清 提交于 2019-12-23 20:05:52
问题 Test case implemented with Python and CherryPy: import cherrypy, time class Root(): @cherrypy.expose def index(self): return r'''<!DOCTYPE html> <html> <head> <title>Server-sent events test</title> <style>html,body,#test{height:98%;}</style> </head> <body> <script type="text/javascript"> document.addEventListener('DOMContentLoaded', function () { var source = new EventSource('gettime'); source.addEventListener('time', function (event) { document.getElementById('test').innerHTML += event.data

What is the difference between Forever-frame and server sent events?

别说谁变了你拦得住时间么 提交于 2019-12-23 13:12:24
问题 This question is really similar with this question:What is the difference between web sockets, long polling, server-sent events and forever frame? However, this question's answer doesn't mention the difference between SSE and Forever-frame. Let me give you brief explanation about them. Regarding to SSE, the system really resembles Comet, but the point which is different with Comet is not breaking the connection after data being sent. So, connection from a server to a client is long-alive and

Ajax polling vs SSE (performance on server side)

有些话、适合烂在心里 提交于 2019-12-23 04:43:25
问题 I'm curious about if there is some type of standard limit on when is better to use Ajax Polling instead of SSE, from a server side viewpoint. 1 request every second: I'm pretty sure is better SSE 1 request per minute: I'm pretty sure is better Ajax But what about 1 request every 5 seconds? How can we calculate where is the limit frequency for Ajax or SSE? 回答1: No way is 1 request per minute always better for Ajax, so that assumption is flawed from the start. Any kind of frequent polling is

Server sent event with Jersey: EventOutput is not closed after client drops

你说的曾经没有我的故事 提交于 2019-12-23 03:47:24
问题 I am using jersey to implement a SSE scenario. The server keeps connections alive. And push data to clients periodically. In my scenario, there is a connection limit, only a certain number of clients can subscribe to the server at the same time. So when a new client is trying to subscribe, I do a check(EventOutput.isClosed) to see if any old connections are not active anymore, so they can make room for new connections. But the result of EventOutput.isClosed is always false, unless the client

SSE (Server-sent events) not working

那年仲夏 提交于 2019-12-23 03:07:18
问题 I'm testing SSE in my Rails app (server: Puma) in Chrome but they are not triggered: setTimeout((function() { console.log("log1"); var source = new EventSource('/websites/21/backlinks/realtime_push'); source.addEventListener('pagination', function(e) { console.log("log2"); var data = JSON.parse(e.data); $('#pagination').html(data.html); }); }), 1); only "log1" is written to console. In developer tools I see XHR requests every time server pushes something (each second) but the response is

Android Push notifications not working when app is closed

孤街浪徒 提交于 2019-12-22 08:09:24
问题 I'm using OkSse to subscribe to my Server Sent Events. Whenever a new message is sent by the server, a notification should appear whether the app is in foreground,minimized or fully closed . The notifications work as expected when minimized or in foreground but when fully closed , this only works on some device brands . Researching a bit, I found that: this issue is noticed only on phones by manufacturers like Xiaomi, Oppo, One Plus, Vivo, Lenovo, Huawei, Samsung, and a few others. How does

How to use server-sent-events in express.js

拟墨画扇 提交于 2019-12-22 06:27:21
问题 I setup my REST server with express.js. Now I want to add sse to this server. After I implemented this sse package, I get an error. I know that I get this error, when would try to use res.send twice, but I am not. ERROR: Error: Can't set headers after they are sent. at ServerResponse.OutgoingMessage.setHeader (http.js:690:11) at ServerResponse.header (/home/root/node_modules/express/lib/response.js:718:10) at ServerResponse.send (/home/root/node_modules/express/lib/response.js:163:12) at app

ASP.NET Web API: PushStreamContent flush does not flush

心不动则不痛 提交于 2019-12-22 05:01:25
问题 I'm using PushStreamContent in ASP.NET Web API to push events from server to client (using Server-Sent Events). After each sent event, I call Flush on the Stream to push the buffered data to the client. However, I noticed that the flushing does not (always) happen. Sometimes, part of the data is sent to the client, and the rest is sent when the next event is written (which could happen seconds later). Here's a code sample: public class MyController : ApiController { private static readonly

How to prevent net::ERR_INCOMPLETE_CHUNKED_ENCODING when using HTML5 Server events and Java Servlets?

a 夏天 提交于 2019-12-22 03:38:20
问题 i just started to play around with Server Events and i run into a chrome error message i would like to understand. i searched the web real quick but didn't find an explanation so i guess i may do something terribly wrong. On the server side i have a simple servlet that accepts requests and creates a dummy event creator task: private Executor executor = Executors.newSingleThreadExecutor(); public void doGet(final HttpServletRequest request, final HttpServletResponse response) { final