I have been trying to implement a client application that
asynchronously receives Server Sent Events. I have been basing it on
the sample code in Chapter 13 of the Jersey 2.0 User Guide
(
https://jersey.java.net/documentation/latest/sse.html#d0e8375).
I have successfully connected to the server and events are being sent
out (I can see them in Wireshark), but my EventListener onEvent method
is never being called.
This is the code I'm using
Client client =
ClientBuilder.newBuilder().register(SseFeature.class).build();
client.register(new HttpBasicAuthFilter("username", "password"));
WebTarget target = client.target(<URL>);
eventSource = new EventSource(target);
eventSource.open();
EventListener listener = new EventListener() {
@Override
public void onEvent(final InboundEvent inboundEvent) {
// Event handling code
}
};
eventSource.register(listener);
I've also tried registering the listener before opening the connection
and overriding the onEvent method in the EventSource class instead of
using an EventListener.
Anyone got any thoughts on what the problem may be or any debugging I
can do ?