This is the extension of my last question here:
socket.io always has connection false
For now, I have two servers deployed in two different domain names. The first server works perfectly fine with socket.io, so I redeployed the server to the new domain name by simply pull the same branch from GitHub, install everything and run it. And then I found that all my socket.io connections failed and the symptom is exactly the same as last time: connection always 'false' and disconnection always 'true'.
This time I am pretty sure it is not related with cors, because I tried io.origins((origin, cb) => if (whitelist.includes(origin)) { cb(null, true) } else { cb('failed', false) ) and it shows the origin is allowed.
I also tried cors: { origin: '*' } and that also doesn't work.
Strangely, despite the fact that they are using the same code, connecting to the first domain name works perfectly fine. But the second one has the issue.
UPDATE:
I use this to track the error message.
this.socket.on('connect_error', function(err) {
console.log(`connect_error due to ${err.message}`);
});
And this is what is returned:
connect_error due to server error
In the mean time, on server side I can see nothing other than the new connections being created and being disconnected due to ping timeout.
Where can I find more information to help me debug?
Turns out I forgot to run npm i after deploying to a new domain name. The version of socket.io wasn't updated and caused that issue.
Everyone who sees this, just make sure you have updated the package before you give up on debugging.