I am trying to implement a TCP server. But it stops taking requests randomly.
I sometimes get following error and I sometimes get the right object that I am sending.
What might cause this?
Browser error:
The connection was reset
The connection to the server was reset while the page was loading.
The site could be temporarily unavailable or too busy. Try again in a few moments.
If you are unable to load any pages, check your computer’s network connection.
If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the Web.
Browser success: (which is the config.tubes object in the server)
{"A":{"key":1,"status":2},"B":{"key":2,"status":0},"C":{"key":3,"status":0}}
Server code
net = require('net');
var server = net.createServer();
PORT = 5000;
ADDRESS = '127.0.0.1';
var server = net.createServer(onClientConnected);
server.listen(PORT);
function onClientConnected(socket) {
console.log(`New client: ${socket.remoteAddress}:${socket.remotePort}`);
socket.write(JSON.stringify(config.tubes));
socket.destroy();
}
console.log(`Server started at: ${ADDRESS}:${PORT}`);
via Soundwave
No comments:
Post a Comment