File tree Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Expand file tree Collapse file tree 1 file changed +7
-1
lines changed Original file line number Diff line number Diff line change @@ -386,7 +386,10 @@ impl C8yAuthRetriever {
386
386
mqtt_config : & mqtt_channel:: Config ,
387
387
topic_prefix : & TopicPrefix ,
388
388
) -> Result < SmartRestJwtResponse , JwtError > {
389
- let mut mqtt_con = Connection :: new ( mqtt_config) . await ?;
389
+ let connection_timeout = Duration :: from_secs ( 30 ) ;
390
+ let mut mqtt_con = tokio:: time:: timeout ( connection_timeout, Connection :: new ( mqtt_config) )
391
+ . await
392
+ . map_err ( |_| JwtError :: MqttConnectionTimeout ( connection_timeout) ) ??;
390
393
let pub_topic = format ! ( "{}/s/uat" , topic_prefix) ;
391
394
392
395
tokio:: time:: sleep ( Duration :: from_millis ( 20 ) ) . await ;
@@ -471,6 +474,9 @@ pub enum JwtError {
471
474
472
475
#[ error( "No JWT token has been received" ) ]
473
476
NoJwtReceived ,
477
+
478
+ #[ error( "Timed out after {0:?} when trying to connect to the local MQTT broker" ) ]
479
+ MqttConnectionTimeout ( Duration ) ,
474
480
}
475
481
476
482
#[ cfg( test) ]
You can’t perform that action at this time.
0 commit comments