Fix: tedge connect c8y --test must not use a persistent MQTT session #2209
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By using a persistent session,
tedge connect c8y --test
might return false positive, telling the connection with c8y is okay, while the received tokens were simply stalled and persisted by mistake. => All MQTT connections used to retrieve JWT token must set the clean session flag to true.To Reproduce
Start as for #2207, but on a device that is actively connected for a while and where
tedge connect c8y --test.
has not been run during this period.sudo up link set wlan down
or just disconnect your network cable.tedge connect c8y --test.
This token was simply persisted by mosquitto.
Simple way to reproduce the issue
tedge connect c8y --test
must not be fooled by a token sent before the connection test.sudo tp link set wlan down
or just disconnect your network cable.tedge mqtt pub c8y/s/dat 71,fake-token --qos 1
tedge connect c8y --test.
tedge connect
wrongly tells the connection is up.Proposed changes
Clear the session flag of the MQTT connection used by
tedge connect c8y --test
Types of changes
Paste Link to the issue
#2207 (comment)
Checklist
cargo fmt
as mentioned in CODING_GUIDELINEScargo clippy
as mentioned in CODING_GUIDELINESFurther comments