@@ -16,7 +16,7 @@ yargs.command('*', false, (yargs: any) => {
16
16
description : "Your AWS IoT custom endpoint, not including a port. " +
17
17
"Ex: \"abcd123456wxyz-ats.iot.us-east-1.amazonaws.com\"" ,
18
18
type : 'string' ,
19
- required : true
19
+ required : true
20
20
} )
21
21
. option ( 'ca_file' , {
22
22
alias : 'r' ,
@@ -40,13 +40,13 @@ yargs.command('*', false, (yargs: any) => {
40
40
alias : 'C' ,
41
41
description : 'Client ID for MQTT connection.' ,
42
42
type : 'string' ,
43
- default : 'samples-client-id'
43
+ required : false
44
44
} )
45
45
. option ( 'topic' , {
46
46
alias : 't' ,
47
47
description : 'STRING: Targeted topic' ,
48
48
type : 'string' ,
49
- default : 'samples/ test'
49
+ default : 'test/topic '
50
50
} )
51
51
. option ( 'count' , {
52
52
alias : 'n' ,
@@ -143,12 +143,12 @@ async function main(argv: Args) {
143
143
const level : io . LogLevel = parseInt ( io . LogLevel [ argv . verbosity . toUpperCase ( ) ] ) ;
144
144
io . enable_logging ( level ) ;
145
145
}
146
-
146
+
147
147
const client_bootstrap = new io . ClientBootstrap ( ) ;
148
148
149
149
let config_builder = null ;
150
- if ( argv . use_websocket ) {
151
- let proxy_options = undefined ;
150
+ if ( argv . use_websocket ) {
151
+ let proxy_options = undefined ;
152
152
if ( argv . proxy_host ) {
153
153
proxy_options = new http . HttpProxyOptions ( argv . proxy_host , argv . proxy_port ) ;
154
154
}
@@ -159,15 +159,15 @@ async function main(argv: Args) {
159
159
proxy_options : proxy_options
160
160
} ) ;
161
161
} else {
162
- config_builder = iot . AwsIotMqttConnectionConfigBuilder . new_mtls_builder_from_path ( argv . cert , argv . key ) ;
162
+ config_builder = iot . AwsIotMqttConnectionConfigBuilder . new_mtls_builder_from_path ( argv . cert , argv . key ) ;
163
163
}
164
164
165
165
if ( argv . ca_file != null ) {
166
166
config_builder . with_certificate_authority_from_path ( undefined , argv . ca_file ) ;
167
167
}
168
-
168
+
169
169
config_builder . with_clean_session ( false ) ;
170
- config_builder . with_client_id ( argv . client_id ) ;
170
+ config_builder . with_client_id ( argv . client_id || "test-" + Math . floor ( Math . random ( ) * 100000000 ) ) ;
171
171
config_builder . with_endpoint ( argv . endpoint ) ;
172
172
173
173
// force node to wait 60 seconds before killing itself, promises do not keep node alive
@@ -179,7 +179,7 @@ async function main(argv: Args) {
179
179
180
180
await connection . connect ( )
181
181
await execute_session ( connection , argv )
182
-
182
+
183
183
// Allow node to die if the promise above resolved
184
184
clearTimeout ( timer ) ;
185
185
}
0 commit comments