You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have a server application that uses Spring's implementation of SSE. This app is deployed on a Tomcat 8.5 server, say on http://localhost:8080/myapp. The 'register' method on this app creates the SseEmitter like this: SseEmitter sseEmitter = new SseEmitter(Long.valueOf(this.TIMEOUT)); SseEventBuilder sseEventBuilder = SseEmitter.event(); sseEventBuilder.reconnectTime(30000); sseEmitter.send(sseEventBuilder);
We have a client application that uses the eventsource-polyfill.js example. the EventSource object is initialized with an endpoint of the server app url and the corresponding open, message and error handlers:
var emitterUrl = 'http://localhost:8080/myapp/register';
this.eventSource=new EventSource(emitterUrl,{withCredentials: true});
//set up EventHandlers
this.eventSource.onopen =this.openHandler;
this.eventSource.onmessage =this.messageHandler;
this.eventSource.onerror =this.errorHandler;
//set up listeners
let list = (event && this.listeners[event.type]) || [];
list.forEach(listener =>this.eventSource.addEventListener(type,event));
The following test behaves as expected:
We start Tomcat and start our app
We access our client app which, on startup, initializes the EventSource object
We shutdown Tomcat completely
Result: the "onConnectionClosed" method is called which calls the error handler method on our client app with the following event:
But in this case we don't get the expected behaviour:
We start Tomcat and start our app
We access our client app which, on startup, initializes the EventSource object
We stop our server app but the tomcat server remains started
Result: On our client app, the error handler method is never called, so it thinks the connection is still active. We believe EventSource should fire an error event in this case.
Tested on eventsource-polyfill.js versions: 1.0.4, 0.2.1
The text was updated successfully, but these errors were encountered:
If I understand correctly, a full shutdown of tomcat will trigger the onerror event in the client.
However, only stopping the server app, but not tomcat, does not trigger the onerror event in the client.
From the EventSource's perspective, the client either has an open http connection or it does not. When the server interrupts the http connection, the onerror event is triggered.
It sounds like stopping the server app doesn't close the http connection, and therefore, onerror isn't triggered in the client.
EventSource connections are long-lived http connections. It's not uncommon for web servers to not shut down until all HTTP connections have finished. With EventSource connections, this never happens, so the shutdown never completes.
You probably need to explicitly close all open EventSource connections before you shut down. Or figure out a way to make that happen automatically.
We are having an issue with the following setup:
We have a server application that uses Spring's implementation of SSE. This app is deployed on a Tomcat 8.5 server, say on http://localhost:8080/myapp. The 'register' method on this app creates the SseEmitter like this:
SseEmitter sseEmitter = new SseEmitter(Long.valueOf(this.TIMEOUT)); SseEventBuilder sseEventBuilder = SseEmitter.event(); sseEventBuilder.reconnectTime(30000); sseEmitter.send(sseEventBuilder);
We have a client application that uses the eventsource-polyfill.js example. the EventSource object is initialized with an endpoint of the server app url and the corresponding open, message and error handlers:
The following test behaves as expected:
Result: the "onConnectionClosed" method is called which calls the error handler method on our client app with the following event:
currentTarget: EventSource
onerror:f()
onmessage:ƒ ()
onopen:ƒ ()
readyState:0
url:"http://localhost:8080/myapp/register"
withCredentials:true
proto:EventSource
defaultPrevented:false
eventPhase:2
isTrusted:true
path:[]
returnValue:true
srcElement: EventSource {url: "http://localhost:8080/myapp/register", withCredentials: true, readyState: 0, onopen: ƒ, onmessage: ƒ, …}
target:EventSource {url: "http://localhost:8080/myapp/register", withCredentials: true, readyState: 0, onopen: ƒ, onmessage: ƒ, …}
type:"error"
But in this case we don't get the expected behaviour:
Result: On our client app, the error handler method is never called, so it thinks the connection is still active. We believe EventSource should fire an error event in this case.
Tested on eventsource-polyfill.js versions: 1.0.4, 0.2.1
The text was updated successfully, but these errors were encountered: