socket.io-client-java icon indicating copy to clipboard operation
socket.io-client-java copied to clipboard

EngineIOException: websocket error

Open lgwghg opened this issue 4 years ago • 5 comments

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 avatar Jul 30 '21 22:07 lgwghg

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

lgwghg avatar Jul 30 '21 22:07 lgwghg

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

GingerAdonis avatar Oct 06 '21 11:10 GingerAdonis

could you fix it ?

efhmedia-dev avatar Jan 21 '22 10:01 efhmedia-dev

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

Areej-Fatima avatar Oct 20 '22 06:10 Areej-Fatima

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

}

ABOBAKAR-IT avatar Jul 04 '23 18:07 ABOBAKAR-IT