Skip to content

Fix: Signature mode fallback never retried connect message#134

Closed
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-signature-mode-fallback
Closed

Fix: Signature mode fallback never retried connect message#134
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-signature-mode-fallback

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 1, 2026

After advancing _signatureTokenMode on a device signature invalid rejection, the client never re-sent the connect message — leaving the WebSocket open but permanently unauthenticated until a full reconnect cycle.

Changes

  • New field _challengeNonce — persists the nonce received in connect.challenge so it's available for retries triggered outside the challenge handler
  • HandleConnectChallenge — stores _challengeNonce alongside the existing _challengeTimestampMs
  • HandleRequestError — after advancing the signature mode, immediately fires SendConnectMessageAsync(_challengeNonce) to retry auth; no retry when all modes are exhausted (mode unchanged)
if (_signatureTokenMode != previousMode)
{
    _logger.Warn($"Gateway rejected device signature with mode {previousMode}; retrying with mode {_signatureTokenMode}");
    _ = SendConnectMessageAsync(_challengeNonce); // was missing — client stuck here
    return;
}

Tests

Four new tests cover: nonce persistence on challenge, per-step mode advancement, connect retry firing on fallback, and full exhaustion of all four modes without a spurious retry.

When the gateway rejects a device signature with 'device signature invalid',
HandleRequestError now re-sends SendConnectMessageAsync with the stored challenge
nonce after advancing _signatureTokenMode to the next fallback mode.

- Add _challengeNonce field to persist the nonce from HandleConnectChallenge
- Store nonce in HandleConnectChallenge before calling SendConnectMessageAsync
- In HandleRequestError, fire SendConnectMessageAsync(_challengeNonce) after
  advancing the signature mode so the client retries immediately
- Add tests for the full fallback behavior and nonce storage

Agent-Logs-Url: https://github.com/openclaw/openclaw-windows-node/sessions/87927bc4-fc20-49ed-9f1d-0b6047452166

Co-authored-by: shanselman <2892+shanselman@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix signature mode fallback to re-send connect message Fix: Signature mode fallback never retried connect message Apr 1, 2026
Copilot AI requested a review from shanselman April 1, 2026 17:28
@shanselman
Copy link
Copy Markdown
Collaborator

Superseded by PR #141 (merged) — signature fallback fix.

@shanselman shanselman closed this Apr 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Signature mode fallback never retries connect message

2 participants