R
R
razer962019-06-07 17:48:21
Nginx
razer96, 2019-06-07 17:48:21

Why am I getting an Invalid Namespace error when connecting to a Socket.io Server?

Hello. On the server, I have Nginx configured for a Socket.io connection.

location /socket.io/ {
                root /var/www/socket.io_service;
                proxy_pass http://localhost:3004;
                proxy_redirect off;
                proxy_http_version 1.1;

                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection "upgrade";
                proxy_set_header Host $host;
                proxy_set_header X-Real-Ip $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }

When connecting from a client to the address, they give an error Invalid namespace
const io = require('socket.io-client')('http://my_server_ip/socket.io/')

Tell me what could be the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CoolMind, 2020-07-28
@CoolMind

Looked at https://www.tutorialspoint.com/socket.io/socket.io... and https://socket.io/docs/namespaces/ . I have an android, there is also such an error. I changed the URL (removed "socket.io/" at the end), after that the error disappeared, and the connection seemed to appear. I will continue searching further.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question