-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closing client socket with auto reconnect enabled #33
Comments
any chance you could provide us a snippet of your code? |
Currently I'm working on a big project with really short deadline, that's how I ran into it, but I'll make a test code when I'll get some time (probably in few days). Just a quickie how to reproduce:
As I said earlier I'll write some code when I'll get some time, if it'll still be necessary. |
Try putting an on 'error' handler like below socket.on('error', function (err) {
log.error('client error', err);
}); |
@enbyted any updates? tnx! |
Thanks for the ping, I forgot about that in the mass of work lately, here is a failing test code: var net = require('net'),
nssocket = require('nssocket');
net.createServer(function (socket) {
console.log('client connected');
}).listen(8345);
var socket = new nssocket.NsSocket({
reconnect: true,
type: 'tcp4',
});
socket.on('start', function () {
console.dir('start');
});
socket.on('error', function (err) {
console.log('client error', err);
});
socket.connect(8345);
setTimeout(function() {
socket.end();
}, 250); So, that will crash with:
If you change the So, there is no way to close an autoreconnect socket. Also, I'm using version '"0.5.3" from NPM repo, I think that's the newest. |
Reconnection logic is now disabled when disconnect is by request (call to .end() or .destroy()).
+1 for merging this. @enbyted can you make a pull request? |
@nucleardreamer There already is one (#34). |
Oh awesome, thank you for writing that! |
When closing client socket with 'reconnect' enabled using
socket.end()
scheduled reconnect function will crash the application (~line 322 in nssocket.js, when removing listeners from socket).If I try
socket.destroy()
reconnect function would recreate the internal socket and connect to server, but it shouldn't, application requested closing of socket.The text was updated successfully, but these errors were encountered: