Describe the bug
After I successfully connected to the server for one minute, an error was reported and the connection was terminated forcibly.
Expected behavior
I hope to know the reason, or ignore the error to keep the connection open.
Debug log
2021-06-22 07:34:40.322 ERROR 54885 --- [ctReadThread-64] org.java_websocket.WebSocketImpl : Closing due to invalid data in frame
org.java_websocket.exceptions.InvalidFrameException: closecode must not be sent over the wire: 60015
at org.java_websocket.framing.CloseFrame.isValid(CloseFrame.java:241)
at org.java_websocket.drafts.Draft_6455.translateSingleFrame(Draft_6455.java:572)
at org.java_websocket.drafts.Draft_6455.translateFrame(Draft_6455.java:739)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:398)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:233)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:516)
at java.base/java.lang.Thread.run(Thread.java:832)
Connection closed by us Code: 1002 Reason: closecode must not be sent over the wire: 60015
org.java_websocket.exceptions.InvalidFrameException: closecode must not be sent over the wire: 60015
at org.java_websocket.framing.CloseFrame.isValid(CloseFrame.java:241)
at org.java_websocket.drafts.Draft_6455.translateSingleFrame(Draft_6455.java:572)
at org.java_websocket.drafts.Draft_6455.translateFrame(Draft_6455.java:739)
at org.java_websocket.WebSocketImpl.decodeFrames(WebSocketImpl.java:398)
at org.java_websocket.WebSocketImpl.decode(WebSocketImpl.java:233)
at org.java_websocket.client.WebSocketClient.run(WebSocketClient.java:516)
at java.base/java.lang.Thread.run(Thread.java:832)
Environment(please complete the following information):
Version used: 1.5.2
Java version: openjdk14
Operating System and version: ubuntu 20.0.4
Endpoint Name and version: test url wss://ws.okex.com:8443/ws/v5/public
Link to your project:
Additional context
Code:
package pro.ails.ant.web.rest;
import org.java_websocket.handshake.ServerHandshake;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.*;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft_6455;
/**
* REST controller for managing {@link pro.ails.ant.domain.OkexKMap}.
*/
@Component
//@RequestMapping("/api")
public class WebSocketCollectResource extends WebSocketClient {
private final Logger log = LoggerFactory.getLogger(WebSocketCollectResource.class);
private static final String ENTITY_NAME = "webSocketCollect";
@Value("${jhipster.clientApp.name}")
private String applicationName;
public WebSocketCollectResource() throws URISyntaxException {
super(new URI("wss://ws.okex.com:8443/ws/v5/public"), new Draft_6455());
this.setProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress("127.0.0.1", 1081)));
this.connect();
}
@Override
public void onOpen(ServerHandshake handshakedata) {
// send("Hello, it is me. Mario :)");
System.out.println("opened connection");
// if you plan to refuse connection based on ip or httpfields overload: onWebsocketHandshakeReceivedAsClient
}
@Override
public void onMessage(String message) {
System.out.println("received: " + message);
}
@Override
public void onClose(int code, String reason, boolean remote) {
// The codecodes are documented in class org.java_websocket.framing.CloseFrame
System.out.println(
"Connection closed by " + (remote ? "remote peer" : "us") + " Code: " + code + " Reason: "
+ reason);
}
@Override
public void onError(Exception ex) {
ex.printStackTrace();
// if the error is fatal then onClose will be called additionally
}
}
Describe the bug After I successfully connected to the server for one minute, an error was reported and the connection was terminated forcibly.
Expected behavior I hope to know the reason, or ignore the error to keep the connection open.
Debug log
Environment(please complete the following information):
Additional context Code: