server-sent-events

Rails app hangs when there's a server sent event (SSE) that requires database actions

半世苍凉 提交于 2020-12-07 06:40:06
问题 I'm learning & doing SSE for the first time in rails! My controller code: def update response.headers['Content-Type'] = 'text/event-stream' sse = SSE.new(response.stream, event: 'notice') begin User.listen_to_creation do |user_id| sse.write({id: user_id}) end rescue ClientDisconnected ensure sse.close end end Front end: var source = new EventSource('/site_update'); source.addEventListener('notice', function(event) { var data = JSON.parse(event.data) console.log(data) }); Model pub/sub class

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

放肆的年华 提交于 2020-08-21 05:56:12
问题 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 response object's close method called, but this doesn't happen when I call EventSource.close() from the client side in Javascript. code on server side: from flask import Response r = Response(stream(), ...) r.call_on_close(on_close) return r def on

PHP Server Sent Events Connection won't close?

£可爱£侵袭症+ 提交于 2020-08-08 05:45:21
问题 I have implemented a server sent events with eventsource on my web application. Basically in javascript my code look like : var myEventSource; if (typeof(EventSource) !== "undefined" && !myJsIssetFunction(viridem.serverSideEvent.config.reindexProcessingEvent)) { myEventSource = new EventSource('/my/url/path.php?event=myevent'); EventSource.onmessage = function(e) { [...] //Dealing with e.data that i received ... } } on the PHP side I have something Like this : <?php header('Content-Type: text

Implement sending Server Sent Events in C# (no ASP.NET / MVC / …)

穿精又带淫゛_ 提交于 2020-07-17 07:02:33
问题 For a project, I need to implement SSE (Server Sent Events) in a C# Application. Although this may sound easy, I've got no clue how to solve this. As I'm new to C# (though, not new to programming in general) I took an excursion to Google and tried to look for some sample code. From what I've seen so far, I could learn to build a HTTP Server with C# or consume server sent events. But I found nothing about sending SSEs. What I'm trying to get my head around: how can I keep sending updated data

Implement sending Server Sent Events in C# (no ASP.NET / MVC / …)

只愿长相守 提交于 2020-07-17 07:02:32
问题 For a project, I need to implement SSE (Server Sent Events) in a C# Application. Although this may sound easy, I've got no clue how to solve this. As I'm new to C# (though, not new to programming in general) I took an excursion to Google and tried to look for some sample code. From what I've seen so far, I could learn to build a HTTP Server with C# or consume server sent events. But I found nothing about sending SSEs. What I'm trying to get my head around: how can I keep sending updated data

Server Sent events with Flask and Google App Engine

情到浓时终转凉″ 提交于 2020-07-08 00:46:10
问题 I've been trying to get a webapp to work which uses Server-Sent Events. The app that I've written works on my local machine when using Flask's app.run() method. But when I run it on GAE, I've not been able to make it work. The webapp uses SSE to publish a message with the current time every so often. The client simply adds it to the HTML of a div. Flask app import random from datetime import datetime from flask import render_template, Response from time import sleep from message_server import

Confuse using Library Server Sent Event for Android Client using Nginx Push Stream

送分小仙女□ 提交于 2020-07-06 04:32:43
问题 Our server is used to Nginx as webserver and add compile module of nginx_push_stream. Before used to push stream had used to Restfull then changed to Websocket but websocket sometimes loss when the client or server had small bandwith. At 2019 year, from Websocekt to Server Sent Event (SSE) / event-source such as event stream or text/event-stream to reduce loss both of client or server. Please anyone have any idea for library event stream is able to use to android client and iPhone client. I

Confuse using Library Server Sent Event for Android Client using Nginx Push Stream

泄露秘密 提交于 2020-07-06 04:27:17
问题 Our server is used to Nginx as webserver and add compile module of nginx_push_stream. Before used to push stream had used to Restfull then changed to Websocket but websocket sometimes loss when the client or server had small bandwith. At 2019 year, from Websocekt to Server Sent Event (SSE) / event-source such as event stream or text/event-stream to reduce loss both of client or server. Please anyone have any idea for library event stream is able to use to android client and iPhone client. I