Basically, if the "server" closes a socket connection, then the first reconnect of the client always immediately closes. The second reconnect succeeds. Here's how to reproduce:I'm using Node 13.8.0Set up the socket in a Node REPL:const net = require('net');const socket = new net.Socket(); socket.on('data', data => console.log(data.toString())); socket.on('end', () => console.log('end')); socket.on('close', () => console.log('close'));Create a socket in another terminal somewhere:rm -f /tmp/test.sock && nc -Ukl /tmp/test.sockConnect to the socket from your Node REPL:socket.connect('/tmp/test.sock');Type messages into the socket and watch them magically appear in your Node REPLCtrl-C kill your socket server.See 'end' and 'close' printed in your REPL.Restart the socket:rm -f /tmp/test.sock && nc -Ukl /tmp/test.sockTry to reconnect in Node:socket.connect('/tmp/test.sock');On my Linux VM, the reconnect is successful and I can see messages typed into the socket. On my Mac, the reconnect immediately receives 'end' and 'close' events!Does this happen for anyone else?
Submitted March 02, 2020 at 04:49PM by ragnese
No comments:
Post a Comment