Skip to content

Commit 4d08393

Browse files
committed
Merge branch 'master' of https://github.com/roccomuso/MQTT.js into roccomuso-master
2 parents c7b5cac + 19015fd commit 4d08393

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

bin/pub.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,15 @@ var mqtt = require('../')
1515
function send(args) {
1616
var client = mqtt.connect(args);
1717
client.on('connect', function() {
18-
client.publish(args.topic, args.message, args);
18+
client.publish(args.topic, args.message, args, function(err) {
19+
if (err) {
20+
console.warn(err);
21+
}
22+
client.end();
23+
});
24+
});
25+
client.on('error', function(err){
26+
console.warn(err);
1927
client.end();
2028
});
2129
}

bin/sub.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,11 @@ function start(args) {
106106
console.log(payload.toString())
107107
}
108108
});
109+
110+
client.on('error', function(err){
111+
console.warn(err);
112+
client.end();
113+
});
109114
}
110115

111116
module.exports = start;

0 commit comments

Comments
 (0)