socketio / socket.io-client-java

Full-featured Socket.IO Client Library for Java, which is compatible with Socket.IO v1.0 and later.
https://socketio.github.io/socket.io-client-java/installation.html
Other
5.32k stars 972 forks source link

EngineIOException: websocket error #682

Open lgwghg opened 3 years ago

lgwghg commented 3 years ago

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。

lgwghg commented 3 years ago

The above address is the address I need to connect to, can you help me try to connect to see where the problem is

GingerAdonis commented 2 years ago

Are you sure this is a socket.io server and not a regular WebSocket server?

efhmedia-dev commented 2 years ago

could you fix it ?

Areej-Fatima commented 1 year ago

I have the same issue. Were you able to fix it?

ABOBAKAR-IT commented 1 year ago

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/;       
   } 

}