0
TCPサーバーを実装しようとしています。しかし、それは要求をランダムに取るのを止める。NodeJs TCPサーバーが要求を一貫して処理しない
私は時々フォローアップエラーが発生し、私はときどき送信しているオブジェクトを取得します。
これはどうしてですか?
ブラウザエラー:
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.
ブラウザの成功:(サーバーでconfig.tubesオブジェクトである)
{"A":{"key":1,"status":2},"B":{"key":2,"status":0},"C":{"key":3,"status":0}}
Serverコード
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}`);
でなければなりません。サーバーへの接続は常に成功します。 – shaochuancs