Repository navigation
fix(c8y): ask for a new token again when a request goes unanswered - #33
Merged
Merged
Conversation
The client reset its 50-minute refresh timer when it sent s/uat, not when the token arrived. One lost reply left a certificate device with its old token until the session restarted: about an hour after it arrived, the token expired, and downloads, log uploads and certificate renewal would get 401. A first request that went unanswered was never repeated at all. The timer now starts when the token arrives, and a request with no answer is repeated after a minute. The decision is a pure helper, tedge_jwt.c, with unit tests. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Problem: a certificate device asks Cumulocity for a token on
s/uat, and the token arrives ons/dat. It uses the token for downloads, log uploads and certificate renewal. The client started its 50-minute refresh timer when it sent the request, not when the token arrived. So:Fix:
The decision is a pure helper,
core/src/tedge_jwt.c(tedge_jwt_request_due), listed underTEDGE_TRANSPORT_C8Yincore/sources.cmake. It has 6 unit tests inports/zephyr/tests/unit: the first request, waiting for an answer, a lost first request, keeping a fresh token, the refresh, and a lost refresh.Checked:
-DTEDGE_WERROR=ON, and its tests pass.Context: this came up while looking into #32 (the NuttX firmware download failing with -104). It is not that bug's cause: those downloads failed with a connection reset, not 401, and the second attempt had a token only seconds old.
🤖 Generated with Claude Code