server-sent-events

H15 on Heroku SSE request

送分小仙女□ 提交于 2019-11-28 12:14:35
I have a Node.js application on Heroku. I've recently switched a long query to use SSE (EventSource). While it works great and fast on my machine, I keep getting an Error H15 (Idle connection) on my GET request. The H15 description says I went over 55 seconds allowed per transaction. But my entire query doesn't take more than 4-5 seconds. Furthermore, after reading the description, I'm returning my first byte (just a number) immediately upon hitting the query, before it starts any heavy work - and it still doesn't work. My question/s are: What do I need to do in order to keep this thing going?

Server Sent Event / EventSource with node.js (express)

左心房为你撑大大i 提交于 2019-11-28 10:31:47
I'm trying to send JSON data to the browser with SSE but I can't seem to get it right and I don't know why. Server side looks like this: var express = require("express"), app = express(), bodyParser = require('body-parser'); app.use(express.static(__dirname + '/')); app.use(bodyParser.urlencoded({ extended: true })); app.use(bodyParser.json()); var testdata = "This is my message"; app.get('/connect', function(req, res){ res.writeHead(200, { 'Connection': 'keep-alive', 'Content-Type': 'text/event-stream', 'Cache-Control': 'no-cache' }); setInterval(function(){ console.log('writing ' + testdata)

SignalR serverSentEvents on Windows Server 2008 with IIS 7 POST request taking too much time to complete

六眼飞鱼酱① 提交于 2019-11-28 05:34:39
问题 I'm using SignalR 2.0.0-beta2 and it's behaving strangely in production environment where an ASP.NET MVC 5 [ .NET Framework 4.5 ] app is installed on Windows Server 2008 with IIS 7 . The AppPool is in Integrated Mode and only has this app. The GET request made by SignalR takes only 60 ms : http://mysite.org.br/signalr/negotiate?clientProtocol=1.3&_=1374377239338 The problem happens with the POST request that takes forever. In the most recent test right now it took incredible 3m 1s : http:/

How do server-sent events actually work?

好久不见. 提交于 2019-11-28 03:56:27
So I understand the concept of server-sent events ( EventSource ): A client connects to an endpoint via EventSource Client just listens to messages sent from the endpoint The thing I'm confused about is how it works on the server. I've had a look at different examples, but the one that comes to mind is Mozilla's: http://hacks.mozilla.org/2011/06/a-wall-powered-by-eventsource-and-server-sent-events/ Now this may be just a bad example, but it kinda makes sense how the server side would work, as I understand it: Something changes in a datastore, such as a database A server-side script polls the

Server-sent events and php - what triggers events on the server?

白昼怎懂夜的黑 提交于 2019-11-28 03:26:15
All, HTML5 Rocks has a nice beginner tutorial on Server-sent Events (SSE): http://www.html5rocks.com/en/tutorials/eventsource/basics/ But, I don't understand an important concept - what triggers the event on the server that causes a message to be sent? In other words - in the HTML5 example - the server simply sends a timestamp once : <?php header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); // recommended to prevent caching of event data. function sendMsg($id, $msg) { echo "id: $id" . PHP_EOL; echo "data: $msg" . PHP_EOL; echo PHP_EOL; ob_flush(); flush(); }

Server Sent Event Client with additional Cookie

人盡茶涼 提交于 2019-11-28 00:11:18
问题 I am trying to unit test a Server Sent Event resource with an additional cookie. I am already using Jersey for the EventSource and JavaX for the client. The following code works fine: WebTarget target = ClientBuilder.newBuilder() .register(SseFeature.class) .build() .target("http://localhost:8080/sse"); EventSource eventSource = EventSource.target(target).build(); EventListener listener = new EventListener() { @Override public void onEvent(InboundEvent inboundEvent) { LOG.info(inboundEvent

JavaScript EventSource SSE not firing in browser

邮差的信 提交于 2019-11-27 21:11:55
I have been developing a nodejs server to provide server-side-events for a new website I am developing in HTML5. When I telnet to the server it works correctly, sending me the required HTTP response headers followed by a stream of events that i am presently generating every 2 or 3 seconds just to prove it works. I have tried the latest version of FireFox, Chrome and Opera and they create the EventSource object and connect to the nodejs server OK but none of the browsers generate any of the events, including the onopen, onmessage and onerror. However, if I stop my nodejs server, terminating the

Server-Sent Events vs Polling

为君一笑 提交于 2019-11-27 18:05:48
Is there a big difference (in terms of performance, browser implementation availability, server load etc) between HTML5 SSEs and straight up Ajax polling? From the server side, it seems like an EventSource is just hitting the specified page every ~3 seconds or so (though I understand the timing is flexible). Granted, it's simpler to set up on the client side than setting up a timer and having it $.get every so often, but is there anything else? Does it send fewer headers, or do some other magic I'm missing? Ajax polling adds a lot of HTTP overhead since it is constantly establishing and

Long Polling with Spring's DeferredResult

非 Y 不嫁゛ 提交于 2019-11-27 16:17:22
问题 The client periodically calls an async method (long polling), passing it a value of a stock symbol, which the server uses to query the database and return the object back to the client. I am using Spring's DeferredResult class, however I'm not familiar with how it works. Notice how I am using the symbol property (sent from client) to query the database for new data (see below). Perhaps there is a better approach for long polling with Spring? How do I pass the symbol property from the method

Angular 2 spring boot server side events

百般思念 提交于 2019-11-27 16:11:16
问题 Can somebody please provide me an example for spring boot server side events? Basically I need to push server side events to browser. I'm using angular 2 and spring boot backend. Please provide me 1 sample example, I'm unable to find good examples. @Controller public class SSEController { private final List<SseEmitter> emitters = new ArrayList<>(); @RequestMapping(path = "/stream", method = RequestMethod.GET) public SseEmitter stream() throws IOException { SseEmitter emitter = new SseEmitter(