server-sent-events

Change source (url) of Server-Sent event

[亡魂溺海] 提交于 2019-11-30 15:38:20
How can I change the source set in declaration of EventSource ? I have tried something like this: var source = new EventSource("/blahblah.php?path=" + (window.location.pathname)); // Few lines later... source.url = "/blahblah.php?path=" + url; But, source.url stays the same... Is this even possible? Or maybe there are alternative ways to do that? No, it is not possible. A new URL passed to EventSource() creates a new EventSource object. guest271314 suggested me much solutions to this, but for me it would be much better, faster and less complicated to stay with sse. I changed the source by

Using RxJs and Angular 2 in order to deal with server-sent events

∥☆過路亽.° 提交于 2019-11-30 14:10:22
问题 I am trying to display server-sent events emitted values in an angular 2 /RxJs app. The backend regularly sends individual strings to the client through server-sent events. I am not sure how to deal with the retrieved values on the angular 2/RxJs side. Here is my client (a ng component): import {Component, OnInit} from 'angular2/core'; import {Http, Response} from 'angular2/http'; import 'rxjs/Rx'; import {Observable} from 'rxjs/Observable'; @Component({ selector: 'my-app', template: `<h1>My

Pyramid stream response body

℡╲_俬逩灬. 提交于 2019-11-30 13:21:25
问题 I'm trying to stream Server-Sent Events from my Pyramid application, but I can't figure out how to stream the response body from my view. Here's the test view I'm using (it totally doesn't implement SSE, it's just to work out the streaming portion): @view_config(route_name='iter_test') def iter_test(request): import time def test_iter(): i = 0 while True: i += 1 if i == 5: raise StopIteration yield str(time.time()) print time.time() time.sleep(1) return test_iter() This produces ValueError:

SSE(EventSource): why no more than 6 connections?

感情迁移 提交于 2019-11-30 13:19:39
问题 I wanted to see how many simultaneous SSE (aka EventSource) connections I could setup, before overloading my machine. But testing with Firefox (Firefox 18 or Firefox 20) it stopped at 6 connections: the additional connections give no error, but do not send any data. (In Firebug I can see them there, waiting to connect.) Chromium 25 also stopped at 6 connections, and so did Opera 12.15. But it does not seem to be a server-side limit (I'm using Apache + PHP), as I could run all three browsers

Debugging HTML5 Server-Sent Events in-browser

早过忘川 提交于 2019-11-30 08:41:50
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.) Visit chrome://cache and click on the URL of the server-sent event. Then you will be redirected to a page

Pyramid stream response body

情到浓时终转凉″ 提交于 2019-11-30 07:03:17
I'm trying to stream Server-Sent Events from my Pyramid application, but I can't figure out how to stream the response body from my view. Here's the test view I'm using (it totally doesn't implement SSE, it's just to work out the streaming portion): @view_config(route_name='iter_test') def iter_test(request): import time def test_iter(): i = 0 while True: i += 1 if i == 5: raise StopIteration yield str(time.time()) print time.time() time.sleep(1) return test_iter() This produces ValueError: Could not convert return value of the view callable function pdiff.views.iter_test into a response

How do server-sent events actually work?

拈花ヽ惹草 提交于 2019-11-30 05:55:45
问题 So I understand the concept of server-sent events ( EventSource ): A client connects to an endpoint via EventSource Client just listens to messages sent from the endpoint The thing I'm confused about is how it works on the server. I've had a look at different examples, but the one that comes to mind is Mozilla's: http://hacks.mozilla.org/2011/06/a-wall-powered-by-eventsource-and-server-sent-events/ Now this may be just a bad example, but it kinda makes sense how the server side would work, as

cURL - Structuring request to validate server sent events

删除回忆录丶 提交于 2019-11-30 04:53:53
问题 I am new to cURL and server sent events. I know how to build a simple GET, POST requests using cURL and getting response. Also, Theoretically I am aware that server sent events are handled by creating a listener to event source but I am not sure how to proceed with validating any such API with cURL. Any guidance is appreciated. 回答1: SSE is a text-based protocol, and curl is a great way to troubleshoot exactly what your connection is sending. The command is this simple: curl -N http://127.0.0

How does Server-Sent-Events work

不问归期 提交于 2019-11-30 03:43:27
I tried an SSE (Server-Sent-Events) using java on tomcat 8.0. Here are few things I noticed. I click a button that automatically makes a request to the servlet. Servlet's GET method gets executed which returns an event stream. Once the full stream is received, the page again automatically makes another request which receives the same data again!!! I don't have an infinite loop there!!! What is actually happening on the server? In normal scenarios, tomcat creates a thread to handle every request. What is happening now? What is the correct way to ensure that the event stream is sent only once to

How to redirect when server-sent-event is finished in Flask on server side?

梦想与她 提交于 2019-11-29 23:00:59
问题 Question How can one redirect to another page when server-sent-event is finished in Flask and on server side? Problem description An EventSource was implemented on client side code (JavaScript) and a Response was returned on server side code (Flask, Python). The EventSource will be closed if the last item from server was sent. I can't see a clear solution to redirect to another site via server side code. Maybe the answer is simple, but I'm not getting it. Similar problem A similar question is