Make heartbeat:0 disable heartbeats#853
Merged
Merged
Conversation
Previously, passing heartbeat:0 was indistinguishable from not setting a heartbeat at all, because negotiate() treats 0 as "no preference". This made it impossible to explicitly disable heartbeats from the client side. Introduces null as the sentinel for "no preference" (accept server value) and handles heartbeat:0 as an explicit instruction to disable heartbeats, sending 0 in the ConnectionTuneOk frame regardless of the server's suggestion. Fixes #467. Co-Authored-By: Claude Opus 4.6 <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.
BREAKING CHANGE — bump to v2.0.0.
heartbeat: 0now correctly disables heartbeats, sending0in theConnectionTuneOkframe regardless of the server's suggestion. This aligns with the AMQP 0-9-1 spec, which definesheartbeat=0as "disabled".Previously,
0was passed throughnegotiate()which treated it as "no preference", causing the server's suggested value to be used instead. The code even had a comment acknowledging the correct intent: "0 means no heartbeat, rather than maximum period of heartbeating".Migration: if you are passing
heartbeat: 0and want to preserve the old behaviour of accepting the server's value, omit the option or passnullinstead.Closes #467. Supersedes #469.
🤖 Generated with Claude Code