POST issue in SSE
Closed this issue · 6 comments
It sounds like you're getting a 403 from the SSE stream. Nothing sse.js
can do about that. Are you sure your stream address loads correctly?
Hi,
It's working fine now thanks.
Hi mpetazzoni,
Is that possible to terminate connection from front end in SSE while response is ended in Backend?
I'm not sure I understand what you mean, but if the server closes the connection, the client will see that connection terminate.
Hi mpetazzoni,
excuse for previous query.my actual query is:
if server side closes the connection,how client side know the connections is terminated.
Is there any flags are sent by the server side,is it mandatory to send the flag (connection is terminate by server side)?
Can you provide sample syntax for above scenario,for both client side(javascript) and server side(JAVA) ?
In Javascript, using an EventSource
, the onReadyState
property will tell you if the connection is closed. You can also setup an event listener on the onreadystatechange
events to be notified when that happens, or on the close
event if your browser supports it (https://developer.mozilla.org/en-US/docs/Web/API/EventSource).
In Java, it would be similar. For example using the Jersey SSE client (https://jersey.java.net/documentation/latest/sse.html#d0e11970) you can use isOpen()
to check the state of the connection.
Hope this helps!