server-sent-events

Server sent events work, but with a massive time delay

|▌冷眼眸甩不掉的悲伤 提交于 2020-01-01 09:19:16
问题 Ill start off by saying this works perfectly on my local machine, the js example below connects to stream.php and receives a continuous update of the servers current time every second. index.php var source = new EventSource("stream.php"); source.addEventListener('message', function(e) { console.log(e); }, false); source.addEventListener('open', function(e) { console.log(e); }, false); source.addEventListener('error', function(e) { if (e.readyState == EventSource.CLOSED) { console.log('closed'

HTML5 Server-Side Event: EventSource vs. wrapped WebSocket

旧时模样 提交于 2020-01-01 06:54:20
问题 Is the HTML5 Server-Sent Events (SSE) API just a restricted, event-based API on top of HTML5 WebSockets? It seems to me that an EventSource is just a WebSocket that: Cannot .send() data Uses the text/event-stream format Fires dynamically-named (server-defined) events instead of onmessage The idea of the web server pushing events down to client devices is quite intriguing. Does this API have any traction? I imagine the async event model would work beautiful when couple with Node, but not

HTML5 Server-Side Event: EventSource vs. wrapped WebSocket

家住魔仙堡 提交于 2020-01-01 06:54:09
问题 Is the HTML5 Server-Sent Events (SSE) API just a restricted, event-based API on top of HTML5 WebSockets? It seems to me that an EventSource is just a WebSocket that: Cannot .send() data Uses the text/event-stream format Fires dynamically-named (server-defined) events instead of onmessage The idea of the web server pushing events down to client devices is quite intriguing. Does this API have any traction? I imagine the async event model would work beautiful when couple with Node, but not

How do I close a Server-Send Events connection in Flask?

淺唱寂寞╮ 提交于 2020-01-01 02:50:06
问题 The below has given an answer using node.js. How to close a "Server-Sent Events"-connection on the server? However, how to do the same thing in python Flask? 回答1: Well, it depends on the architecture of your app. Let me show you an example (see this code at https://github.com/jkbr/chat/blob/master/app.py): def event_stream(): pubsub = red.pubsub() pubsub.subscribe('chat') for message in pubsub.listen(): print message yield 'data: %s\n\n' % message['data'] @app.route('/stream') def stream():

Server Sent Events pass parameter by post method

 ̄綄美尐妖づ 提交于 2019-12-29 05:56:31
问题 I'm using Html5 Server Sent Events. The server side is Java Servlet. I have a json array data wants to pass to server. var source = new EventSource("../GetPointVal?id=100&jsondata=" + JSON.stringify(data)); If the array size is small , the server side can get the querystring. But if the array size is big. (maybe over thousands of characters), the server can't get the querystring. Is it possible to use POST method in new EventSource(...) to to pass the json array to server that can avoid the

Server Sent Events pass parameter by post method

不想你离开。 提交于 2019-12-29 05:56:24
问题 I'm using Html5 Server Sent Events. The server side is Java Servlet. I have a json array data wants to pass to server. var source = new EventSource("../GetPointVal?id=100&jsondata=" + JSON.stringify(data)); If the array size is small , the server side can get the querystring. But if the array size is big. (maybe over thousands of characters), the server can't get the querystring. Is it possible to use POST method in new EventSource(...) to to pass the json array to server that can avoid the

Server-Sent Events via MVC, get simultaneously result and error

ε祈祈猫儿з 提交于 2019-12-25 16:46:25
问题 I tried to get SSE technology and couldn't resolve one trouble. Always triggered two event onmessage and error. I have getting valid date and simultaneously error message. Why this happening and how to resolve this ? How to prolong live time of connection "polltransport request" ?? Here server side public class HomeController : Controller { public ActionResult Message() { JavaScriptSerializer ser = new JavaScriptSerializer(); var serializedObject = ser.Serialize(new { item = "fuck", message =

How to loadtest server sent events

心不动则不痛 提交于 2019-12-25 08:47:52
问题 I have a node service that streams data via SSE (https://www.npmjs.com/package/sse-channel). I would like to loadtest this service my making 'n' concurrent connections, i tried the "loadtest" npm module but since we are dealing with streaming responses i was not able to report back any data like requests per second, mean latency etc… when the streaming requests are made, is there a way to use "loadtest" module for streaming services if not can someone point me to the module that would report

How to close a “Server-Sent Events”-connection on the server?

北慕城南 提交于 2019-12-24 17:07:02
问题 Regarding this specification: http://www.w3.org/TR/eventsource/ How does one close the opened connection on the server? Client-side wise it is easy, just call close() , but what should I do on the server? Just kill it? 回答1: node.js: http.createServer(function (req, res) { //... // client closes connection res.socket.on('close', function () { res.end(); //... }); }); see example for implementation of SSE server in node.js: https://github.com/Yaffle/EventSource/blob/master/nodechat/server.js

How to have multiple clients listen to a server sent event?

谁说胖子不能爱 提交于 2019-12-24 10:35:48
问题 I am trying to get my head around server sent events. The rest of my site is served using cherrypy, so I want to get them working on this platform too. The method I'm using to expose the SSE: @cherrypy.expose def interlocked(self, _=None): cherrypy.response.headers["Content-Type"] = "text/event-stream;charset=utf-8" if _: data = 'retry: 400\n' while not self.interlockUpdateQueue.empty(): update = self.interlockUpdateQueue.get(False) data += 'data: ' + str(update) + '\n\n' return data else: