Skip to content

Fix: drain stale LOGOUT responses during login#19

Merged
halacs merged 1 commit intohalacs:masterfrom
alexbartok:fix/login-session-drain
Apr 1, 2026
Merged

Fix: drain stale LOGOUT responses during login#19
halacs merged 1 commit intohalacs:masterfrom
alexbartok:fix/login-session-drain

Conversation

@alexbartok
Copy link
Copy Markdown
Contributor

The gateway sends a LOGOUT frame for each stale session before the actual LOGIN response. Previously, Login() would fail with "received unexpected packet" if a stale LOGOUT arrived first (the existing TODO comment on line 345 of Client.go notes this issue).

This change drains up to 20 stale LOGOUT frames before processing the login response. Also extracts receiveResponse() as a reusable helper and simplifies transmitCommand() to use it.

Observed on a ProMatic 3 (firmware EE001425-14): stale sessions accumulate when connections are closed without sending LOGOUT (e.g. after crashes or network interruptions). The gateway then floods LOGOUTs on the next login attempt.

Thanks to @halacs for this project, which was essential for building my own garage door integration.

The gateway sends a LOGOUT frame for each stale session before the
actual LOGIN response. Previously, Login() would fail with "received
unexpected packet" if a stale LOGOUT arrived first.

Now drains up to 20 stale LOGOUT frames before processing the login
response. Also extracts receiveResponse() as a reusable helper and
simplifies transmitCommand() to use it.
Comment thread sdk/Client.go
@halacs halacs merged commit aa480e2 into halacs:master Apr 1, 2026
2 of 3 checks passed
@halacs
Copy link
Copy Markdown
Owner

halacs commented Apr 1, 2026

Thank you for your contribution!

@alexbartok alexbartok deleted the fix/login-session-drain branch April 1, 2026 20:01
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.

2 participants