server-sent-events

Server-Sent Events with multiple users

家住魔仙堡 提交于 2019-12-19 03:58:11
问题 I'm attempting to write a chat program with the new Server-Sent Events API, however, I've been having trouble figuring out how to send different users different events. With all the code occurring out of one PHP file, I'm unsure the best way to send only certain events to each user. Any help you can give would be greatly appreciated. (I'm working in PHP and Javascript) 回答1: Lets say the following is your sender.php code (one php file) echo "event: ping\n"; $msg1="This is first user"; echo

EventSource permanent auto reconnection

那年仲夏 提交于 2019-12-19 03:39:13
问题 I am using JavaScript EventSource in my project front-end. Sometimes, the connection between the browser and the server fails or the server crashes. In these cases, EventSource tries to reconnect after 3 seconds, as described in the documentation. But it tries only once. If there is still no connection, the EventSource stops to try reconnection and the user have to refresh the browser window in order to be connected again. How I can prevent this behavior? I need the EventSource to try

HTTP: what are the relations between pipelining, keep-alive and Server Sent Events?

这一生的挚爱 提交于 2019-12-18 13:15:53
问题 I am trying to understand what are the HTTP pipelining and HTTP keep-alive connections, and trying to establish a connection between these two topics and Server Sent events technology. As far as I understand, HTTP keep-alive connection is the default in HTTP 1.1 way of using TCP when the established once TCP connection is used for sending several HTTP requests one by one. HTTP pipelining is the capability of client to send requests to server while responses to previous requests were not yet

Debugging HTML5 Server-Sent Events in-browser

一曲冷凌霜 提交于 2019-12-18 13:05:06
问题 Is there any way of viewing/debugging Server-Sent Events in Chrome (or perhaps Firefox)? I was hoping they'd appear in the Network tab of Chrome's developer tools. The closest way I know of is to drop down to Wireshark, but this is fairly cumbersome in comparison. For example, go to http://www.emojitracker.com/. You'll see the page updating in real time with data from the server, but no activity appears in the network tab. (It subscribes to server events on line 97 of /application.js.) 回答1:

How to make Server sent events (SSE) work trough Zuul Proxy spring-boot 2.1.1

那年仲夏 提交于 2019-12-18 09:14:14
问题 I have some issues getting SSE working trough my zuul reverse proxy My setup: Spring boot version: 2.1.1.RELEASE Spring cloud dependencies: Greenwich.RC1 Angular-cli: Angular 7 Kotlin: 1.3.11 os: Linux I have a small rest service that uses SSE @SpringBootApplication @RestController @CrossOrigin("http://localhost:19195") class RestApplication { private final val processor = DirectProcessor.create<Int>().serialize() private final val sink = processor.sink() private final val counter =

Server-Sent Events Polling causing long delays

♀尐吖头ヾ 提交于 2019-12-17 17:07:58
问题 I have a connector that will call a RESP API using cURL and PHP. I need to call one method every second to check for new messages and then process them. I used the following 2 approaches to handle the messages AJAX Polling using SetInterval() : call the php script once every second. This works perfectly except I am unable to prevent multiple SetInterval() from running at the same time from different tabs of the browser. ( I don't want to have user opens 10 browser tabs which leads to one user

server sent events (eventsource) with standard asp.net mvc causing error

一世执手 提交于 2019-12-17 07:34:09
问题 I am trying my hand at server-sent events, but I cannot get it to work within an MVC project (not WebAPI). I haven't found any good samples online. This is the server-side code I tried (including several failed attempts from various posts): Function GetRows() as ActionResult Dim ret = New HttpResponseMessage ' ret.Content.w ' Return ret Response.ContentType = "text/event-stream" Response.Write("data: " & "aaaa") Dim flag = False If flag Then For i = 0 To 100 Response.Write("data: " & i) Next

Server Sent Events with CORS support

≡放荡痞女 提交于 2019-12-13 18:28:38
问题 I am using Server Sent Events in ServiceStack and I need to allow its use across origins. I have setup the ServiceStack CorsFeature in my application, but this is not honoured by the ServerEventsFeature . I can manually add the Access-Control-Allow-Origin header in the OnCreated , and that allows requests to event-stream , but requests to the heartbeat fail, because I cannot set a header on this request. Plugins.Add(new ServerEventsFeature { HeartbeatInterval = new TimeSpan(0,0,30), OnCreated

Server Sent Event and asp classic

风流意气都作罢 提交于 2019-12-13 16:04:16
问题 I made a ASP script with all headers necessary for Server Sent Events. The client side script is working. I tested it with a PHP script and it works fine. The ASP script works and it returns the expected message if you call it from the URL line, but when the javascript calls it, the element inspector returns the data as "undefined". When I set the breakpoint to the "open" event listener, the "e.data" is "undefined". For some reason Javascript is not accepting the UTF-8 text sent by the ASP

Eventsource API : EXCEPTION: No activity within 300000 milliseconds. Reconnecting

我的未来我决定 提交于 2019-12-13 04:22:54
问题 I am using eventSource API and added the addEventListener() to the eventsouce. The event source is activated till only 45 seconds. I want to keep the connection alive until the server send the response back to client. Now, I am getting the below exception because there is no response back from the server till 45 secs. EXCEPTION: No activity within 300000 milliseconds. Reconnecting. Please give me some pointers to make the connection alive/ any other approach to achieve it. 回答1: The solution