server-sent-events

How can i stop a server sent event script from running when the user closes the page? PHP

寵の児 提交于 2019-12-13 01:55:11
问题 Im trying to use SSE in PHP backend to send messages to a user. the functional part of the backend code looks like- <?php set_time_limit(0); header('Content-Type: text/event-stream'); header('Cache-Control: no-cache'); ignore_user_abort(0); @session_start(); ob_start(); echo "retry: 1000\n"; ob_flush(); flush(); require_once 'sql_connection_class.php'; require 'chatbox_class.php'; $chatbox=new chatboxclass($_GET['friendid']); function recursivesenddata(){ global $chatbox; $jsonobj=$chatbox-

Firebase Server Sent Events - How to build a Java / JavaScript client

走远了吗. 提交于 2019-12-12 22:16:59
问题 I am new to Firebase and building a prototype to test if suitable for our needs. I've got a chat example up and running, so far so good. Next is the need to listen for changes. I have tried connecting to the REST API supporting server sent events using both Java and JavaScript, but I can not make it work. In Java I have written the following code: public class FirebaseApplication { @Test public void test() throws Exception{ Client client = ClientBuilder.newBuilder() .register(SseFeature.class

SSE implementation in Spark REST

拟墨画扇 提交于 2019-12-12 21:28:58
问题 Looking for a simple example of a GET rest api that produces text/event-stream. How do I keep a track of listeners, how to use emitter in spark? Basically, how do I achieve SSE using spark framework (Server side code) 来源: https://stackoverflow.com/questions/45826776/sse-implementation-in-spark-rest

Does Heroku support ActionController::Live?

怎甘沉沦 提交于 2019-12-12 18:17:06
问题 I have a Rails app hosted on Heroku and I want to add Server Sent Events functionalities, but I can't find any documentation or blog post specific for Heroku. As not all servers (e.g. WEBrick) support ActionController::Live I was wondering what is the default server on Heroku and whether is possible to configure the environment (i.e. change server) to support SSEs. Any further advice about the server to use and how to configure would be greatly appreciated. 回答1: I think my answer is not so

What is the WebSockets alternative in the HTTP/2 world?

扶醉桌前 提交于 2019-12-12 09:56:15
问题 The new HTTP/2 protocol comes with some promising features. Some of them: Multiplexing - a single TCP connection can be used to make multiple HTTP/2 requests and receive multiple responses (to a single origin) HTTP/2 Server Push - sending server responses to the client without receiving requests, i.e. initiated by the server Bidirectional connection - HTTP/2 spec - Streams and Multiplexing: A "stream" is an independent, bidirectional sequence of frames exchanged between the client and server

Handling event-stream connections in a Sinatra app

房东的猫 提交于 2019-12-12 08:18:18
问题 There is a great example of a chat app using Server-Sent Events by Konstantin Haase. I am trying to run it and have a problem with callbacks (I use Sinatra 1.3.2 and browse with Chrome 16). They simply do not run (e.g. after page reload), and therefore the number of connections is growing. Also, connection is closed in 30-60 sec unless one sets a periodic timer to send empty data, as suggested by Konstantin elsewhere. Can you replicate it? If yes, is it possible to fix these issues somehow?

How do I configure IIS 7.5 for SSE (Server Sent Events) and SignalR

ぐ巨炮叔叔 提交于 2019-12-12 07:57:34
问题 I have tested my Asp.NET MVC application to run SignalR and it properly handles the text/event-stream MIME with a serverSentEvents connection, using Visual Studio 2012, IIS Express (Microsoft-IIS/8.0) and Chrome. Now that I am deploying to production environment (IIS 7.5, .NET Framework 4.5, Windows Server 2008R2), I've noticed that SignalR always falls back to LongPolling transport, since the signalr/connect?transport=serverSentEvents etc times out. Is there a way to configure Microsoft-IIS

How to detect a disconnection as soon as it happens on ASP.NET without polling?

不想你离开。 提交于 2019-12-12 06:05:54
问题 I have a server-sent events handler in ASP.NET Response.ContentType = "text/event-stream"; while (true) { if(thereIsAMessage) { Response.Write(message); Response.Flush(); if (Response.IsClientConnected == false) { break; } } System.Threading.Thread.Sleep(1000); } The problem is that I can only detect a client disconnection when I send something to the client. And I don't want to poll it, which defeats the whole purpose of using Server-sent events in the first place. 回答1: Try to look at

Named event stream with Play 2.5 and server sent events

二次信任 提交于 2019-12-12 04:02:54
问题 Default event name/type in server sent event is "message". I am trying to change the event name but it is not working. I am using Play 2.5 and akka streams. (actorRef,sourcePublisher)= Source .actorRef[T](10, OverflowStrategy.fail) .toMat(Sink.asPublisher(true))(Keep.both) .run() backsource = Source.fromPublisher[T](sourcePublisher).named("test1") Ok.chunked(backsource via EventSource.flow) .as(ContentTypes.EVENT_STREAM) But it is not changing the event name/type. It is still listening to

Reading SSE data in python

谁说我不能喝 提交于 2019-12-12 03:23:50
问题 I have a SSE server(eg: http://www.howopensource.com/2014/12/introduction-to-server-sent-events/) that sends output as given below. Each data section is separated with two new lines(\n\n). I want to write down a simple python program to display the SSE output continuously. ... id: 5 data: Got ID: 5 and the data will be like this. id: 6 data: Got ID: 6 and the data will be like this. id: 7 data: Got ID: 7 and the data will be like this. ... I tried following python code. from __future__ import