Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Is it possible to set a single peer’s HeartbeatTimeout to 0 with v7?#1774

Discussion options

Exception when setting a single peer’s HeartbeatTimeout to 0 with v7.

After following the migration guide, tutorials and other suggestions made via the useful posts here, I’ve upgraded from v6 to v7. I’ve encountered the same “ArgumentOutOfRangeException” when using a HeartbeatTimeout of 0, as reported inIssue #1756. My RabbitMQ HeartbeatTimeout setup along with the results of my investigations into the issue are detailed below.

What I’d like to know is whether my v6 HeartbeatTimeout setup is still possible in v7?

Thanks very much for taking a look at this post.

Environment: RabbitMQ v3.13.2, Erlang v26.2.4.

My RabbitMQ setup with RabbitMQ.Client v6 (.NET).
Required behaviour: A heartbeat of 60 secs.

Client HeartbeatTimeout = 0.
Server HeartbeatTimeout = 60 (using default value as heartbeat absent from rabbitmq.conf).

Result = Connection created with a HeartbeatTimeout of 60 secs.

This behaviour is as described in the documentationDetecting Dead TCP Connections with Heartbeats and TCP Keepalives | RabbitMQ and below:

Java, .NET and Erlang clients maintained by the RabbitMQ core team use the following negotiation algorithm:
•If either value is 0 (see below), the greater value of the two is used

A zero value indicates that a peer suggests disabling heartbeats entirely. To disable heartbeats, both peers have to opt in and use the value of 0. “

Note: My setup has no requirement to disable heartbeats which is why, only the client’s heartbeat is set to 0. This setup works well as every new client simply has its HeartbeatTimeout set to 0, which, when running the v6 client, always results in the new connection having a heartbeat of 60 secs.

My RabbitMQ setup with RabbitMQ.Client v7 (.NET).
Required behaviour: A heartbeat of 60 secs.

Client HeartbeatTimeout = 0.
Server HeartbeatTimeout = 60 (using default value as heartbeat absent from rabbitmq.conf).

Result = System.ArgumentOutOfRangeException: Timeout can be only be set to 'System.Threading.Timeout.Infinite' or a value > 0. (Parameter 'value').

The stack trace below directs you to the SocketFrameHandler.ReadTimeout property which is where the exception is being raised whilst trying to set the System.Net.Sockets.NetworkStream.ReadTimeout property.

at System.Net.Sockets.NetworkStream.set_ReadTimeout(Int32 value) in /_/src/libraries/System.Net.Sockets/src/System/Net/Sockets/NetworkStream.cs:line 135at System.Net.Security.SslStream.set_ReadTimeout(Int32 value) in /_/src/libraries/System.Net.Security/src/System/Net/Security/SslStream.cs:line 652at RabbitMQ.Client.Impl.SocketFrameHandler.set_ReadTimeout(TimeSpan value) in /_/projects/RabbitMQ.Client/Impl/SocketFrameHandler.cs:line 121at RabbitMQ.Client.ConnectionFactory.ConfigureFrameHandler(IFrameHandler fh) in /_/projects/RabbitMQ.Client/ConnectionFactory.cs:line 630at RabbitMQ.Client.ConnectionFactory.<CreateFrameHandlerAsync>d__142.MoveNext() in /_/projects/RabbitMQ.Client/ConnectionFactory.cs:line 611at RabbitMQ.Client.EndpointResolverExtensions.<SelectOneAsync>d__0`1.MoveNext() in /_/projects/RabbitMQ.Client/IEndpointResolverExtensions.cs:line 87

v6 SocketFrameHandler.ReadTimeout property:

if (_socket.Connected) { _socket.ReceiveTimeout = value; }

v7 SocketFrameHandler.ReadTimeout property:
_stream.ReadTimeout is new here in v7. It was previously set in the constructor in v6.

try { _socket.ReceiveTimeout = value; _stream.ReadTimeout = (int)value.TotalMilliseconds; }

You must be logged in to vote

v7 now allows a client to set its Heartbeat Timeout value to 0 thanks to PR#1773.

This is the same behaviour as v6 and results in the connections' Heartbeat either:

  • being set to the servers' Heartbeat Timeout value
    or
  • being disabled where the servers' Heartbeat Timeout is also 0 (as we know this isn't recommended)

Replies: 3 comments 1 reply

Comment options

@justcuriousstill see#1773.

It is a really questionable configuration to use, disabling heartbeats is only recommended if you useTCP keepalives instead on all hosts across your system.

You must be logged in to vote
0 replies
Comment options

Thanks for the in-depth analysis. Yep, I'm working on this when I have time away from supporting RabbitMQ customers.

You must be logged in to vote
1 reply
@justcuriousstill
Comment options

Thanks for the quick response confirming this is already being looked into. All the tremendous work that goes into this product is really appreciated.

Comment options

v7 now allows a client to set its Heartbeat Timeout value to 0 thanks to PR#1773.

This is the same behaviour as v6 and results in the connections' Heartbeat either:

  • being set to the servers' Heartbeat Timeout value
    or
  • being disabled where the servers' Heartbeat Timeout is also 0 (as we know this isn't recommended)
You must be logged in to vote
0 replies
Answer selected byjustcuriousstill
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
3 participants
@justcuriousstill@michaelklishin@lukebakken

[8]ページ先頭

©2009-2025 Movatter.jp