Error while disconnecting client.
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}
Because you did not send a DISCONNECT message.
client.end() ?
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.
yes. got it. I did something like this, and it worked... ;)
process.once('SIGINT', function () { client.end(); process.exit(0); })
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?
You will see that log message. It is an error from the broker point of view.