@@ -29,8 +29,8 @@ class Agent {
29
29
}
30
30
} ) . json ( )
31
31
32
+ // console.log(`creds: ${JSON.stringify(this.creds,null, 2)}`)
32
33
this . creds = Object . assign ( this . creds , { reconnectPeriod : 0 } )
33
- // console.log(this.creds)
34
34
35
35
if ( this . creds . ssl ) {
36
36
switch ( this . creds . protocol ) {
@@ -44,9 +44,6 @@ class Agent {
44
44
}
45
45
46
46
const options = {
47
- protocol : this . creds . protocol ,
48
- host : this . creds . host ,
49
- port : this . creds . port ,
50
47
clientId : this . creds . clientId ,
51
48
protocolVersion : this . creds . protocolVersion ,
52
49
username : this . creds . credentials . username ,
@@ -57,13 +54,15 @@ class Agent {
57
54
options . rejectUnauthorized = false
58
55
}
59
56
57
+ const url = `${ this . creds . protocol } //${ this . creds . host } :${ this . creds . port } `
58
+ // console.log(url)
60
59
// console.log(options)
61
60
62
61
// this.client = mqtt.connect(`${this.creds.protocol}//${this.creds.hostname}:${this.creds.port}`, this.creds)
63
- this . client = mqtt . connect ( options )
62
+ this . client = mqtt . connect ( url , options )
64
63
this . client . on ( 'connect' , function ( ) {
65
64
agent . connected = true
66
- console . log ( `connected to ${ options . host } :${ options . port } as ${ options . clientId } ` )
65
+ console . log ( `connected to ${ agent . creds . host } :${ agent . creds . port } as ${ options . clientId } ` )
67
66
agent . error = null
68
67
agent . client . subscribe ( '#' )
69
68
} )
0 commit comments