-
Notifications
You must be signed in to change notification settings - Fork 10
Description
I am running a node server as a bridge client to a remote mosquitto server. The code is basically cloned from https://github.com/strongloop/strong-pubsub-example commenting out the helper to spawn mosquitto process and add a mosquito 'host' parameter in Client. Before running 'node server.js', I just run "mosquitto -p 6000 -v" in an remote machine.
var Client = require('strong-pubsub');
var Proxy = require('strong-pubsub-bridge');
tcpServer.on('connection', function(socket) {
var proxy = new Proxy(
// upgrade the tcp socket into a strong-pubsub-connection
new Connection(socket),
new Client({host: '192.168.1.71', port: MOSQUITTO_PORT}, Adapter)
);
proxy.connect();
});
The 'node pub' and 'node sub' runs fine like the original unmodified repos. Unlike the original behavior, ctrl-c to terminate 'node sub' would produce an error and exit 'node server' process. Would I be able to handle this situation and detect that the socket error is causing by termination of one of the subscribers?
My guess is this is a ECONNRESET type of situation that the remote mosquito server detect the connection is closed abruptly and err out to the node server client. The error is not there if the helper code is used like the original repos.. I cannot use helper since it doesn't seem to deal with connecting remote MQTT server host....
TCP server listening at port 4000
events.js:141
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at exports._errnoException (util.js:870:11)
at TCP.onread (net.js:544:26)