I have a websocket setup using javax.websocket, it seems to connect, but wont work, it keeps giving a java.lang.IllegalStateException: Binary message handler not found
final WebSocketContainer webSocketContainer = ContainerProvider.getWebSocketContainer();
Session session = webSocketContainer.connectToServer(new Endpoint() {
@Override
public void onError(Session session, Throwable thr) {
// TODO Auto-generated method stub
super.onError(session, thr);
System.out.println("checkerWindow.DownloadMessages().new Endpoint() {...}.onError()");
thr.printStackTrace();
}
@Override
public void onOpen(Session session, EndpointConfig EndpointConfig) {
System.out.println("checkerWindow.DownloadMessages().new Endpoint() {...}.onOpen()");
try {
//send login details
//login:<deviceid>:<secret>\n
session.getBasicRemote().sendText("login:"+deviceid+":"+secret+"\n");
}
catch(Exception ex){
System.err.println("Exception=" + ex.toString());
ex.printStackTrace();
}
}
@OnMessage
public void onMessage(String message) {
System.out.println("Received message: "+message);
}
@Override
public void onClose(Session session, CloseReason closeReason) {
System.out.println("checkerWindow.DownloadMessages().new Endpoint() {...}.onClose()");
}
}, ClientEndpointConfig.Builder.create().build(), URI.create("wss://client.pushover.net/push"));
I have tried the ByteBuffer but the compiler doesnt like that.
You should define a method to receive binary messages. For example,
@OnMessage
public void onMessage(byte[] message) {
......
}
See the JavaDoc of OnMessage annotation for details.