I have a personal userscript enabled on an HTTPS website. The userscript is using Socket.io client API to make a connection to a Node.js TCP server in my PC
The server notices that the client is connecting to the server, but the client doesn't notice the connection and instead receives this error from the browser console
Failed to load resource: net::ERR_TIMED_OUT
I don't know how to resolve this error, but I'm assuming it has something to due with Socket.io and Net being incompatible with each other or the website is not allowing the connection to happen
Here is my client code
socket.on('connect', function() {
console.log('CONNECTED TO SERVER');
socket.on('message', function(msg) {
messageReceive(msg);
});
setInterval(runRoutine, 1000);
});
My sever code
var net = require('net');
var clients = [];
var port = 8841;
net.createServer(function(socket) {
socket.name = socket.remoteAddress + ':' + socket.remotePort;
clients.push(socket);
broadcast(socket.name + " has connected to the server", socket);
socket.on('message', function(data) {
broadcast(socket.name + "<>" + data, socket);
});
socket.on('end', function() {
clients.splice(clients.indexOf(socket), 1);
broadcast(socket.name + '<>disconnected', socket);
});
function broadcast(message, sender) {
console.log(message);
clients.forEach(function(client) {
if(client === sender) return;
//client.write(message);
});
}
}).listen(port);
console.log("Chat server running at port " + port);