socketio / socket.io-client

Realtime application framework (client)
https://socket.io
10.63k stars 3.04k forks source link

Socketio connected successfully, but console says "WebSocket connection to "wss:.." failed #1493

Closed vincentsartoko closed 7 months ago

vincentsartoko commented 3 years ago

The connection to the socket works, because here is my code (React):

socket.current = io("www.ohezo.com", { auth: { id } });
socket.current.on("open", () => {
    console.log("It worked");
}

Once the client receives something from the socket listener "open", it will no longer show the loading screen, but let's just put console.log for simplicity. Everything works fine, I opened another tab and I can send chat, friend requests, etc.

However, inside the console I got this error: image

If you have any clue on the error please let me know thank you!

Stevenzwzhai commented 3 years ago

how to resolve this error

vincentsartoko commented 3 years ago

@Stevenzwzhai you need to redirect the request to wss instead of http, are you using VPS?

ltfschoen commented 1 year ago

to resolve an error like that try:

darrachequesne commented 7 months ago

For future readers:

This might indicate that something between the server and your browser is preventing the WebSocket connection.

More information here: https://socket.io/docs/v4/troubleshooting-connection-issues/#problem-the-socket-is-stuck-in-http-long-polling

Please reopen if needed.