diff options
author | PradeepKiruvale <pradeepkumar.kj@softwareag.com> | 2022-02-15 20:04:04 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-15 20:04:04 +0530 |
commit | 25e806d6f50a0d4e834927c9e0c23e4c0550ad52 (patch) | |
tree | 39e23d434bed18c3150a0ca8c716526e90f911b9 | |
parent | 0b8048c53eb69777f3a053c9e46fd53dfcc478f1 (diff) |
[860] tedge connection check c8y timeout (#861)
* return error on timeout
* update message on connection check failure
-rw-r--r-- | crates/core/c8y_translator/fuzz/Cargo.lock | 8 | ||||
-rw-r--r-- | crates/core/tedge/src/cli/connect/command.rs | 20 |
2 files changed, 17 insertions, 11 deletions
diff --git a/crates/core/c8y_translator/fuzz/Cargo.lock b/crates/core/c8y_translator/fuzz/Cargo.lock index 3cd1c8b5..583f365e 100644 --- a/crates/core/c8y_translator/fuzz/Cargo.lock +++ b/crates/core/c8y_translator/fuzz/Cargo.lock @@ -25,7 +25,7 @@ checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" [[package]] name = "c8y_translator" -version = "0.5.1" +version = "0.5.2" dependencies = [ "chrono", "clock", @@ -69,7 +69,7 @@ dependencies = [ [[package]] name = "clock" -version = "0.5.1" +version = "0.5.2" dependencies = [ "chrono", "mockall", @@ -118,7 +118,7 @@ checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" [[package]] name = "json-writer" -version = "0.5.1" +version = "0.5.2" dependencies = [ "serde_json", "thiserror", @@ -331,7 +331,7 @@ checksum = "507e9898683b6c43a9aa55b64259b721b52ba226e0f3779137e50ad114a4c90b" [[package]] name = "thin_edge_json" -version = "0.5.1" +version = "0.5.2" dependencies = [ "chrono", "clock", diff --git a/crates/core/tedge/src/cli/connect/command.rs b/crates/core/tedge/src/cli/connect/command.rs index 18052a03..6363efbf 100644 --- a/crates/core/tedge/src/cli/connect/command.rs +++ b/crates/core/tedge/src/cli/connect/command.rs @@ -74,12 +74,18 @@ impl Command for ConnectCommand { let br_config = self.bridge_config(&config)?; if self.check_if_bridge_exists(&br_config) { return match self.check_connection(&config) { - Ok(_) => { + Ok(DeviceStatus::AlreadyExists) => { let cloud = br_config.cloud_name.clone(); - println!("Connection check to {} cloud is successfull.\n", cloud); + println!("Connection check to {} cloud is successful.\n", cloud); + Ok(()) + } + _ => { + println!( + "Connection check to {} cloud failed.\n", + self.cloud.as_str() + ); Ok(()) } - Err(err) => Err(err.into()), }; } else { return Err((ConnectError::DeviceNotConnected { @@ -131,7 +137,7 @@ impl Command for ConnectCommand { match self.check_connection(&config) { Ok(DeviceStatus::AlreadyExists) => { - println!("Connection check is successfull.\n"); + println!("Connection check is successful.\n"); } _ => { println!( @@ -236,7 +242,7 @@ where } // Check the connection by using the jwt token retrival over the mqtt. -// If successfull in getting the jwt token '71,xxxxx', the connection is established. +// If successful in getting the jwt token '71,xxxxx', the connection is established. fn check_device_status_c8y(tedge_config: &TEdgeConfig) -> Result<DeviceStatus, ConnectError> { const C8Y_TOPIC_BUILTIN_JWT_TOKEN_DOWNSTREAM: &str = "c8y/s/dat"; const C8Y_TOPIC_BUILTIN_JWT_TOKEN_UPSTREAM: &str = "c8y/s/uat"; @@ -273,7 +279,7 @@ fn check_device_status_c8y(tedge_config: &TEdgeConfig) -> Result<DeviceStatus, C } Ok(Event::Outgoing(Outgoing::PingReq)) => { // No messages have been received for a while - println!("Local MQTT publish has timed out."); + eprintln!("ERROR: Local MQTT publish has timed out."); break; } Ok(Event::Incoming(Incoming::Disconnect)) => { @@ -345,7 +351,7 @@ fn check_device_status_azure(port: u16) -> Result<DeviceStatus, ConnectError> { } Ok(Event::Outgoing(Outgoing::PingReq)) => { // No messages have been received for a while - println!("Local MQTT publish has timed out."); + eprintln!("ERROR: Local MQTT publish has timed out."); break; } Ok(Event::Incoming(Incoming::Disconnect)) => { |