Reputation: 23
I am working on a node.js site that uses socket.io on ports 8443 and port 443. The site works locally as well as using namecheap for dns records pointing to the production server. I recently set the nameservers to Cloudflare and added the same A record there that I was using at namecheap. Now everything works except for the socket.io to port 443. Requests using port 443 that are not using socket.io are working fine.
I am getting this error:
GET https://<domain>/socket.io/?EIO=3&transport=polling&t=M8UDaUZ 404 ()
Port 8443 socket.io requests are getting 200 responses, and include an sid:
https://<domain>:8443/socket.io/?EIO=3&transport=polling&t=M8UDUTx&sid=cuq1LLdLLVSj2F4FAAAN
I am not sure if the sid missing on the port 443 requests indicates the problem. When I asked cloudflare support about it, their response was 404 means to check the path.
The only thing that has changed is the DNS so I don't think this can be a path problem or a code problem with the site. It seems like it has to be something Cloudflare is doing differently than namecheap for dns or socket.io connections.
I don't see any other errors. Does anyone know what the problem could be or how to fix it for Cloudflare?
Upvotes: 1
Views: 628
Reputation: 23
Have you managed to solve the issue? I was dealing with the same issue (or looked the same) and what helped me was setting sockets.io listen to HTTP server.
Server code:
var http = require('http');
var server = https.createServer(app).listen(80, function() {
console.log('Express HTTP server listening');
});
var io = require('socket.io').listen(server);
var secureServer = https.createServer(httpsOptions, app);
console.log('Express HTTPS server listening');
});
Client uses wss:// (so transport is secure).
Also I have CloudFlare option "proxy all HTTP to HTTPS" enabled.
Upvotes: 1