File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -15,7 +15,15 @@ var mqtt = require('../')
15
15
function send ( args ) {
16
16
var client = mqtt . connect ( args ) ;
17
17
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 ) ;
19
27
client . end ( ) ;
20
28
} ) ;
21
29
}
Original file line number Diff line number Diff line change @@ -106,6 +106,11 @@ function start(args) {
106
106
console . log ( payload . toString ( ) )
107
107
}
108
108
} ) ;
109
+
110
+ client . on ( 'error' , function ( err ) {
111
+ console . warn ( err ) ;
112
+ client . end ( ) ;
113
+ } ) ;
109
114
}
110
115
111
116
module . exports = start ;
You can’t perform that action at this time.
0 commit comments