-
Notifications
You must be signed in to change notification settings - Fork 840
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change heartbeat negotiation strategy #874
Conversation
if client_value > 0 then this value should be used as heartbeat. because sometimes, the max value of client_value and the server_value may too big for firmwall, the firmwall may have broken off the connection.
Codecov Report
@@ Coverage Diff @@
## master #874 +/- ##
=======================================
Coverage 81.98% 81.98%
=======================================
Files 20 20
Lines 3664 3664
Branches 545 545
=======================================
Hits 3004 3004
Misses 513 513
Partials 147 147
Continue to review full report at Codecov.
|
This is generally in line with what Bunny and Java client do (https://github.com/ruby-amqp/bunny/blob/master/lib/bunny/session.rb#L1172, https://github.com/ruby-amqp/bunny/blob/master/lib/bunny/session.rb#L1259) but I'd like to take a closer look. |
I confirmed that Java client does the same thing (which is not surprising given that with Bunny we tried to copy most of those decisions). Therefore Pika should, too. |
@michaelklishin leave some flexibility to users ... |
…eference client Java client and some others (Bunny, .NET) use a slightly different negotiation logic. See #874 comments for details. With this change, in some cases when previously heartbeats were disabled, they will be enabled now. Arguably this is an improvement because disabling heartbeats is rarely a good idea (unless all machines run with sensible TCP keepalive settings, which is a rare thing to come by). Closes #874.
@zjj I don't think "flexibility" is a good enough justification for inconsistent behaviour between clients when it comes to heartbeat negotiation. Or perhaps I misunderstood your comment. I pushed an update that changes heartbeat negotiation logic to be the same as in Java client, which accomplishes the same goal: the smallest value of the two will be used when both client and server provide non-zero values. |
Releasing this in 0.11.1 seems OK: for the majority of users nothing will change. In other cases a lower value will be used, which is safe unless the values are really low (< 5 seconds is known to produce false positives often enough). Arguably this is a bug fix: the logic is now consistent with that of multiple other widely used clients (Java, .NET, Bunny) and it's closer to "doing the right thing" if you consider what the goal of having heartbeats in the protocol is. |
@michaelklishin your patch is ok, but I think it's not good for pika to have its own cleaver policy to choose a value. it's a user's duty ??? |
Is 0 supposed to still turn off heartbeats? If so it looks like there's still an issue related to recent changes in the 11.1 or 11.2 release:
With this there's no way 0 can turn off heartbeats, unless the server is set to 0 as well which invalidates the purpose of the 0 switch. Else if the functionality has changed the doc should be updated to indicate that 0 no longer switches off heartbeats. |
@jordanburke see Michael's commit 3027890 |
…eference client Java client and some others (Bunny, .NET) use a slightly different negotiation logic. See pika#874 comments for details. With this change, in some cases when previously heartbeats were disabled, they will be enabled now. Arguably this is an improvement because disabling heartbeats is rarely a good idea (unless all machines run with sensible TCP keepalive settings, which is a rare thing to come by). Closes pika#874.
if client_value > 0 then this value should be used as heartbeat.
because sometimes, the max value of client_value and the
server_value may too big for firmwall, the firmwall may have broken
off the connection.