Skip to content

Commit

Permalink
Merge pull request #2420 from PradeepKiruvale/qos0
Browse files Browse the repository at this point in the history
use qos 0 when publishing to c8y/s/uat to request a Cumulocity IoT token
  • Loading branch information
reubenmiller authored Nov 6, 2023
2 parents 9dea122 + 7250a07 commit abfd325
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
8 changes: 4 additions & 4 deletions crates/core/c8y_api/src/http_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ impl C8yMqttJwtTokenRetriever {
for _ in 0..3 {
mqtt_con
.published
.publish(mqtt_channel::Message::new(
&Topic::new_unchecked("c8y/s/uat"),
"".to_string(),
))
.publish(
mqtt_channel::Message::new(&Topic::new_unchecked("c8y/s/uat"), "".to_string())
.with_qos(mqtt_channel::QoS::AtMostOnce),
)
.await?;
info!("JWT token requested");

Expand Down
8 changes: 4 additions & 4 deletions crates/core/tedge/src/cli/connect/bridge_config_c8y.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ impl From<BridgeConfigC8yParams> for BridgeConfig {
r#"alarm/alarms/create out 2 c8y/ """#.into(),
r#"error in 2 c8y/ """#.into(),
// c8y JWT token retrieval
r#"s/uat out 2 c8y/ """#.into(),
r#"s/dat in 2 c8y/ """#.into(),
r#"s/uat out 0 c8y/ """#.into(),
r#"s/dat in 0 c8y/ """#.into(),
];

let templates_set = smartrest_templates
Expand Down Expand Up @@ -199,8 +199,8 @@ fn test_bridge_config_from_c8y_params() -> anyhow::Result<()> {
r#"alarm/alarms/create out 2 c8y/ """#.into(),
r#"error in 2 c8y/ """#.into(),
// c8y JWT token retrieval
r#"s/uat out 2 c8y/ """#.into(),
r#"s/dat in 2 c8y/ """#.into(),
r#"s/uat out 0 c8y/ """#.into(),
r#"s/dat in 0 c8y/ """#.into(),
// Smartrest templates should be deserialized as:
// s/uc/template-1 (in from localhost), s/uc/template-1
// s/dc/template-1 (out to localhost), s/dc/template-1
Expand Down
7 changes: 6 additions & 1 deletion crates/core/tedge/src/cli/connect/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,12 @@ fn check_device_status_c8y(tedge_config: &TEdgeConfig) -> Result<DeviceStatus, C
match event {
Ok(Event::Incoming(Packet::SubAck(_))) => {
// We are ready to get the response, hence send the request
client.publish(C8Y_TOPIC_BUILTIN_JWT_TOKEN_UPSTREAM, AtLeastOnce, false, "")?;
client.publish(
C8Y_TOPIC_BUILTIN_JWT_TOKEN_UPSTREAM,
rumqttc::QoS::AtMostOnce,
false,
"",
)?;
}
Ok(Event::Incoming(Packet::PubAck(_))) => {
// The request has been sent
Expand Down
7 changes: 6 additions & 1 deletion crates/core/tedge/src/cli/connect/jwt_token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,12 @@ pub(crate) fn get_connected_c8y_url(tedge_config: &TEdgeConfig) -> Result<String
match event {
Ok(Event::Incoming(Packet::SubAck(_))) => {
// We are ready to get the response, hence send the request
client.publish(C8Y_TOPIC_BUILTIN_JWT_TOKEN_UPSTREAM, AtLeastOnce, false, "")?;
client.publish(
C8Y_TOPIC_BUILTIN_JWT_TOKEN_UPSTREAM,
rumqttc::QoS::AtMostOnce,
false,
"",
)?;
}
Ok(Event::Incoming(Packet::PubAck(_))) => {
// The request has been sent
Expand Down

0 comments on commit abfd325

Please sign in to comment.