В настоящее время я расширяю AbstractWebSockethandler , но, хотя я вижу, что существует handlepongmessage () , метод не есть (). handlemessage () реализация): < /p>
Код: Выделить всё
public class MyHandler extends AbstractWebSocketHandler {
// some other methods here...
@Override
public void handleMessage(@NonNull WebSocketSession session, @NonNull WebSocketMessage message) {
try {
if (message instanceof PingMessage) {
log.info("Received Ping from server. Sending Pong."); // I never see this log in the console when running a program
session.sendMessage(new PongMessage(((PingMessage) message).getPayload()));
return;
} else if (! (message instanceof TextMessage)) return;
String s = (String) message.getPayload();
// doing some processing here...
} catch (Exception e) {
log.error("Failed to read json data");
}
}
}
Moreover, after some time my websocket gets disconnected from the server with the following error: Disconnected from websocket with code 1006 and reason "Unexpected Status of SSLEngineResult after an unwrap() operation"
And I assume this happens due to not handling the ping messages.
Thank you a lot for your time!
Подробнее здесь: https://stackoverflow.com/questions/794 ... -websocket