0

I'm currently using websocket library on both nodejs backend and JS client.

I'm trying to change to socket.io, I managed to write the code for both sides however I'm unable to connect to the server from my client.

On the console of my browser I see the error and realised that the address is being changed by the socketio library.

websocket: wss://domain.com/asset-ws/ ==> works fine

socketio: auto changes the url to wss://domain.com/socket.io/?EIO=4&transport=websocket

The error: WebSocket connection to 'wss://domain.com/socket.io/?IO=4&transport=websocket' failed.

Is it something to do with my nginx config?

Any help would be much appreciated.

Thank you

1 Answer 1

0

By default socket.io url adds the /socket.io path.

In my Nginx config I'm already using a custom path add, so I just specified a path on the io server config, like so:

const io = new Server(server, {
  path: '/' 
});

This way the default path would be overwritten.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.