after investigation it seems that proxying the websocket through httpd
is timing out the connection. as it is not happening on my local machine
On 17/07/2021 12:59, Matthew Broadhead wrote:
Trying to broadcast to all sessions on a WebSocket but it is a bit hit
and miss. the WebSocket is got by
DefaultServerEndpointConfigurator dsec = new
DefaultServerEndpointConfigurator();
NewsWebSocket nws = dsec.getEndpointInstance(NewsWebSocket.class);
nws.broadcast(myString);
and in the WebSocket I am trying to broadcast on looks like this
@ServerEndpoint(value = "/websockets/admin/news")
public class NewsWebSocket {
private static final Set<Session> sessions =
Collections.synchronizedSet(new HashSet<Session>());
// ... @OnOpen, @OnMessage, @OnClose, @OnError
public void broadcast(String string) {
synchronized (sessions) {
for (Session session : sessions) {
try {
session.getBasicRemote().sendText(string);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}
}
}
I also tried adding an "@Observes @MyEvent MyEvent blah" and firing an
"Event<MyEvent>" but the breakpoint is never reached