socket.io-client-java
socket.io-client-java copied to clipboard
EngineIOException: websocket error
Server version: unknown Client version:2.0.1
I use JS connection in the webpage and it works fine。 But in java, I have used various versions of the client, and it keeps prompting websocket errors,and no more tips 。
My code: `
URI uri = URI.create("https://cross.bet");
IO.Options options = IO.Options.builder()
.setTimeout(60000)
.setTransports(new String[]{WebSocket.NAME})
.setSecure(true)
.build();
Socket socket = IO.socket(uri, options);
socket.on(Socket.EVENT_CONNECT, objects -> System.out.println("Connection established"));
socket.on(Socket.EVENT_CONNECT_ERROR, objects -> System.out.println(Arrays.toString(objects)));
socket.connect();`
or
`
IO.Options options = IO.Options.builder()
.setTimeout(60000)
.setTransports(new String[]{WebSocket.NAME})
.setSecure(true)
.build();
Socket socket = IO.socket("wss://cross.bet", options);
socket.on(Socket.EVENT_CONNECT, objects -> System.out.println("Connection established"));
socket.on(Socket.EVENT_CONNECT_ERROR, objects -> System.out.println(Arrays.toString(objects)));
socket.connect();`
Any version is this error
io.socket.engineio.client.EngineIOException: websocket error
I really hope someone can help me。
The above address is the address I need to connect to, can you help me try to connect to see where the problem is
Are you sure this is a socket.io server and not a regular WebSocket server?
could you fix it ?
I have the same issue. Were you able to fix it?
on remote server config the nginx for socket.io
server
{ server_name backend.me;
location /{
# proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
# proxy_set_header X-NginX-Proxy true;
proxy_pass http://localhost:4000/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
# proxy_redirect http://localhost:5000/ https://$server_name/;
}
}