server-sent-events

Flask server sent events socket exception

為{幸葍}努か 提交于 2019-12-06 02:24:33
问题 I am thinking of using SSE to push new data to the client and using Flot(javascript charting library) display "live" updates. My server runs on python Flask framework and I have figured out how to push the data to the client, but the problem occurs as soon as I leave the page: Exception happened during processing of request from ('127.0.0.1', 38814) Traceback (most recent call last): File "/usr/lib/python2.7/SocketServer.py", line 582, in process_request_thread self.finish_request(request,

Using Django Server Sent Events with Database post save

我与影子孤独终老i 提交于 2019-12-05 23:37:19
问题 I am trying to implement Server Sent Events(SSE) in Django Framework. It is clear to me that I can implement a view like this: @csrf_exempt def event_stream(request): def eventStream(): yield "data:Server Sent Data\n\n" response = HttpResponse(eventStream(), content_type="text/event-stream") response['Cache-Control'] = 'no-cache' return response But I want to trigger the SSE call whenever a new entry is made in a database table, from the post_save of the table, How I might be able to achieve

SSE implementation in Spring REST

蹲街弑〆低调 提交于 2019-12-05 17:15:28
Can anybody provide an example for SSE ( Server sent events) using Spring Rest ? Basically i have a request and the response for it would be sent by the server in multiple chunks. I would like to have the server and client implementation in Spring REST Api without third party rest api like jersey. There isn't any direct support for SSE in Spring currently but it looks like it will be available in 4.2 which is in RC2 right now You can see the details here https://jira.spring.io/browse/SPR-12212 This works via returning an SseEmitter or a ResponseBodyEmitter from the controller methods.

Angular2/typescript and SSE (EventSource)

为君一笑 提交于 2019-12-05 10:27:44
First of all, I`m quite new to ng2 and typescript. What Im trying to accomplish is to implement Server-Sent events in Angular2 component. I have followed the examples mentioned in earlies posts here, but my problem is that the "EventSource" object is unrecognized (red underline, in VS Code). Im not sure if I`m missing some references... My references are: <!-- IE required polyfills, in this exact order --> <script src="node_modules/es6-shim/es6-shim.min.js"></script> <script src="node_modules/systemjs/dist/system-polyfills.js"></script> <script src="node_modules/angular2/es6/dev/src/testing

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

依然范特西╮ 提交于 2019-12-05 09:31:31
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.get.str (/home/root/.node_app_slot/main.js:1330:25) at Layer.handle [as handle_request] (/home/root

ASP.NET Web API: PushStreamContent flush does not flush

混江龙づ霸主 提交于 2019-12-05 05:41:56
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 string[] LineSeparators = new[] { Environment.NewLine }; public HttpResponseMessage GetData(string id) {

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

爱⌒轻易说出口 提交于 2019-12-04 23:50:55
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: <?php while(true) { echo "data: This is the message."; sleep(3); ob_flush(); flush(); } ?> I expect that every 3 seconds, "data: This is the message." will be outputted. Instead, the page just doesn't load. However, I need this behavior for server-sent events. Is there a way to fix this? Edit: Full Code: <?php session_start(); require "connect.php"; require "user.php";

Server Sent Events and Rails Streaming

旧时模样 提交于 2019-12-04 18:05:23
问题 I'm experimenting with Rails 4 ActionController::Live and Server Sent Events. I'm using MRI 2.0.0 and Puma. For what I can see, each connected client keeps an active connection to the server. I was wondering if it is possible to leverage SSEs without keeping all response streams running. Puma manages multiple connections using threads, and I imagine there is a limit to the number of cuncurrent connections. What if I want to support a real-world scenario with thousands of clients registering

Server-sent events inside Laravel

旧城冷巷雨未停 提交于 2019-12-04 15:02:39
I am trying to implement the HTML5 Server-sent events inside Laravel 4, I found this repo the script uses server.php file to get it working. My question is how would I implement it to get it working with a Controller instead of a plain php file? So in the Javascript side it will look like this: var source = EventSource('/notifications'); I tried this just to see if I get a response: class NotificationsController extends BaseController { public function index() { $response = Response::view('notifications.index'); $response->header('Content-Type', 'text/event-stream'); $response->header('Cache

pyserial reading serial port in flask (maybe using gevent)

被刻印的时光 ゝ 提交于 2019-12-04 14:28:07
问题 I'm building a webserver that would need to read (and keep reading) the serial port of the machine it's running on. The purpose is to be able to read a barcode scanner, and using Server-Sent Events to update a browser with the read barcode. I'm using flask to do this. I've browsed around and some implementations require only flask, some say I would need an async library like Gevent, and some others even say I'd need Gevent and some sort of queue like Redis or RabbitMQ. I've tried to base my