[client] stream_measurements: survive the 2h session expiry (re-auth before WS re-handshake) #158

Closed
opened 2026-10-27 10:06:14 +00:00 by mat · 0 comments
Owner

The cwt_session cookie lives login + 2 h (the x-cwt-token header of
POST /api/v1/authent, see docs/energy.comwatt.com/auth.md), and the same
cookie authenticates the wss://frontage.energy.comwatt.com/ws handshake.
A stream_measurements subscription can therefore outlive the session:
the server cuts the socket at expiry, and the existing reconnect=True
path re-handshakes — with a cookie that may be dead.

  • Verify where the WS handshake cookie comes from (does it go through
    _request? If yes, #99's reactive auto_reauth / opt-in
    proactive_reauth already covers the re-handshake; if no, route it so
    it does, or re-auth explicitly before re-handshaking).
  • Consider using session_expires_at (from #99) to re-auth ahead of the
    2h boundary during long streams instead of eating the disconnect.
  • refreshtoken is not a session refresh (see #70 field notes) — do
    not chase that endpoint.

Related: #99 (x-cwt-token capture + proactive re-auth), #101 (ping/stop
frames — orthogonal but same long-lived-stream robustness theme).

The `cwt_session` cookie lives **login + 2 h** (the `x-cwt-token` header of `POST /api/v1/authent`, see docs/energy.comwatt.com/auth.md), and the same cookie authenticates the `wss://frontage.energy.comwatt.com/ws` handshake. A `stream_measurements` subscription can therefore outlive the session: the server cuts the socket at expiry, and the existing `reconnect=True` path re-handshakes — with a cookie that may be dead. - Verify where the WS handshake cookie comes from (does it go through `_request`? If yes, #99's reactive `auto_reauth` / opt-in `proactive_reauth` already covers the re-handshake; if no, route it so it does, or re-auth explicitly before re-handshaking). - Consider using `session_expires_at` (from #99) to re-auth ahead of the 2h boundary during long streams instead of eating the disconnect. - `refreshtoken` is **not** a session refresh (see #70 field notes) — do not chase that endpoint. Related: #99 (x-cwt-token capture + proactive re-auth), #101 (ping/stop frames — orthogonal but same long-lived-stream robustness theme).
mat closed this issue 2026-10-27 10:27:12 +00:00
Sign in to join this conversation.
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
mat/python-comwatt-client#158
No description provided.