mosca icon indicating copy to clipboard operation
mosca copied to clipboard

Error while disconnecting client.

Open PritamUpadhyay opened this issue 11 years ago • 6 comments

Why nodejs mosca server shows following error whenever client is disconnect.?

{"name":"mosca","hostname":"CI5W8P111401","pid":5260,"client":"54neL2pyzR","level":40,"err":{"message":"read ECONNRESET" ,"name":"Error","stack":"Error: read ECONNRESET\n at exports._errnoException (util.js:746:11)\n at TCP.onread (net .js:559:26)","code":"ECONNRESET"},"msg":"read ECONNRESET","time":"2015-06-08T13:58:13.855Z","v":0}

PritamUpadhyay avatar Jun 08 '15 14:06 PritamUpadhyay

Because you did not send a DISCONNECT message.

mcollina avatar Jun 08 '15 14:06 mcollina

client.end() ?

PritamUpadhyay avatar Jun 08 '15 14:06 PritamUpadhyay

client.end() in MQTT.js should send a disconnect message. But there might be a race and that does not get delivered before the process is closed. Try adding a callback and a console.log.

mcollina avatar Jun 08 '15 14:06 mcollina

yes. got it. I did something like this, and it worked... ;)

process.once('SIGINT', function () { client.end(); process.exit(0); })

PritamUpadhyay avatar Jun 08 '15 14:06 PritamUpadhyay

A quick question on this. What about the situation when say there is a device which looses connection (very bad network area). So maybe it cannot send a client.end(). How should we handle that?

neilunadkat avatar Dec 31 '15 09:12 neilunadkat

You will see that log message. It is an error from the broker point of view.

mcollina avatar Dec 31 '15 09:12 mcollina