server-sent-events

jax-rs sse client with Singleton in Glassfish/Payara

倖福魔咒の 提交于 2019-12-11 03:04:43
问题 About jax-rs client with SSE in EJB Singleton, I've tried with Payara server full-5.183 (without docker) for this example, [https://abhirockzz.wordpress.com/2017/07/27/jax-rs-2-1-sse-client-api-example-using-glassfish-5-on-docker/], but failed. Error shown at line eventSource = SseEventSource.target(target).build(); @PostConstruct public void init() { this.sseClient = ClientBuilder.newClient(); this.target = this.sseClient.target("https://sse.now.sh"); tsvc.createSingleActionTimer(15000, null

How to load test Server Sent Events?

拈花ヽ惹草 提交于 2019-12-11 01:09:38
问题 I have a small app that sends Server Sent Events. I would like to load test my app so I can benchmark the latency from the time a message is pushed to the time the message is received so I can know when/where the performance breaks down. What tools are available to be able to do this? 回答1: Since Server-Sent Events it is just HTTP you can use siege utility. Here is the example: siege -b -t 1m -c45 http://127.0.0.1:9292/streaming Where: -b benchmark mode i.e. don't wait between connections -t

increase Service Worker life time

做~自己de王妃 提交于 2019-12-10 22:06:00
问题 I'm trying push notifications using service workers. use my own server to send notifications and eventSource is used to establish the connection. after i open the webpage service worker is running perfectly. but it stops after few seconds. what i want is to run service worker without getting stopped. i want it to run until the browser is opened. can anyone recommend a way to do that. ? this is my ServiceWorker JS /** * */ 'use strict'; var eventSource2 = new EventSource("Servlet"); console

does service worker request, response from server continuously?

岁酱吖の 提交于 2019-12-10 19:38:28
问题 I'm using server send event to display a notification.I have created a service worker and i used EventSource to connect with the server (in my case i used a servlet. ) once i run the project. everything is working fine. but the contents inside the event execute countiously. I want to know why? my other question is once i close the tab. it stops sending notification. service worker is nunning and server also running. but why it stops? this is my service worker code. var eventSource = new

Spring SseEmitter causes Cannot forward after response has been committed exception

夙愿已清 提交于 2019-12-10 18:25:17
问题 Given a simple controller with a method like this: @RequestMapping(method = RequestMethod.GET, value = "{id}/update") public ResponseEntity<SseEmitter> update() throws IOException { final SseEmitter sseEmitter = new SseEmitter(); return ResponseEntity.ok(sseEmitter); } I tried it this way also: @RequestMapping(method = RequestMethod.GET, value = "{id}/update") public SseEmitter update() throws IOException { final SseEmitter sseEmitter = new SseEmitter(); return sseEmitter; } But both way

How to pass POST parameters with HTML SSE?

这一生的挚爱 提交于 2019-12-10 17:12:02
问题 I've got a block of code here that uses HTML 5 SSE - the EventSource object, which lets a php script push updates to the webpage. However, I'm interested in also passing parameters to the script. How can I do that? Here's the code: if(typeof(EventSource) !== "undefined") { var source = new EventSource("get_message.php"); source.onmessage=function(event) { document.getElementById("message-window").innerHTML+=event.data + "<br>"; }; } else { document.getElementById("message-window").innerHTML=

How to fully implement server-sent events for message polling

拈花ヽ惹草 提交于 2019-12-10 16:35:40
问题 I am trying to communicate with a server using an API. to make it easier I wrote a script that will communicate the API using a php script. My goal is to make a query to the API every second to see if there is new message in their queue. I was advised to use server-sent events method and have the server send a respond to the client only when it has something new. Here is my php script <?php // Register autoloader function spl_autoload_register('apiAutoloader'); header("Content-Type: text

Jersey Server-Sent Events - write to broken connection does not throw exception

时间秒杀一切 提交于 2019-12-10 15:24:28
问题 We are using Jersey Server-Sent Events (SSE) to allow remote components of our application to listen to events raised by our Jersey/Tomcat server. This works great. However, it is crucial that our server have an accurate list of currently-connected listeners (our remote components). To this end, our server sends a tiny message to each caller (via eventOutput.write) once every five seconds. If our remote component is shut down while SSE-connected, or if the remote computer is powered off while

EventSource disconnects after first message

拥有回忆 提交于 2019-12-10 11:40:15
问题 A bit confused about EventSource behavior. It connects well and stays connected until it receives first message. As i send a data: something\n\n message, the connection is dropped and new one created. Using Content-Type: text/event-stream header and the connection are recognized as a event stream and the inspector shows pending status. As i said, everything works well until i send first message. After this the connection are interrupted and new one created and message not sent to browser(at

EventSource and basic http authentication

☆樱花仙子☆ 提交于 2019-12-10 02:46:51
问题 Does anyone know if it is possible to send basic http authentication credentials with EventSource? 回答1: EventSource is about the server sending events to the client. I think you need bidirectional communication for authentication. How would you otherwise send the actual credentials? WebSockets, however, can achieve that. Is that what you are looking for? Update: You can achieve what you want by utilizing cookies, as pointed out by 4esn0k. Cookies are sent along with the initial request that