Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions crates/common/mqtt_channel/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,18 @@ impl Config {
}
}

/// Set the random session name with prefix and clear the session
pub fn with_session_prefix(self, prefix: impl Into<String>) -> Self {
let random: String = std::iter::repeat_with(fastrand::lowercase)
.take(10)
.collect();
Self {
session_name: Some(format!("{}-{}", prefix.into(), random)),
clean_session: true,
..self
}
}

/// Unset the session name and clear the session
pub fn with_no_session(self) -> Self {
Self {
Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge/src/cli/connect/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub async fn check_device_status_aws(

let mut mqtt_options = tedge_config
.mqtt_config()?
.with_session_name(CLIENT_ID)
.with_session_prefix(CLIENT_ID)
.rumqttc_options()?;
mqtt_options.set_keep_alive(RESPONSE_TIMEOUT);

Expand Down
2 changes: 1 addition & 1 deletion crates/core/tedge/src/cli/connect/azure.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ pub(crate) async fn check_device_status_azure(

let mut mqtt_options = tedge_config
.mqtt_config()?
.with_session_name(CLIENT_ID)
.with_session_prefix(CLIENT_ID)
.rumqttc_options()?;

mqtt_options.set_keep_alive(RESPONSE_TIMEOUT);
Expand Down
6 changes: 2 additions & 4 deletions crates/core/tedge/src/cli/connect/c8y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,7 @@ pub(crate) async fn check_device_status_c8y(

let mut mqtt_options = tedge_config
.mqtt_config()?
.with_session_name(CLIENT_ID)
.with_clean_session(true)
.with_session_prefix(CLIENT_ID)
.rumqttc_options()?;

mqtt_options.set_keep_alive(RESPONSE_TIMEOUT);
Expand Down Expand Up @@ -323,8 +322,7 @@ pub(crate) async fn get_connected_c8y_url(

let mut mqtt_options = tedge_config
.mqtt_config()?
.with_session_name(CLIENT_ID)
.with_clean_session(true)
.with_session_prefix(CLIENT_ID)
.rumqttc_options()?;
mqtt_options.set_keep_alive(RESPONSE_TIMEOUT);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ tedge_connect_test_positive
${output}= Execute Command sudo tedge connect c8y --test stdout=${False} stderr=${True}
Should Contain ${output} Connection check to c8y cloud is successful.

Multiple tedge connect test processes can run concurrently
[Tags] \#3907
Execute Command sudo tedge connect c8y --test & sudo tedge connect c8y --test timeout=5

Non-root users should be able to read the mosquitto configuration files #2154
[Tags] \#2154
Execute Command sudo tedge connect c8y || true
Expand Down