File tree Expand file tree Collapse file tree 1 file changed +7
-4
lines changed
projects/client/RabbitMQ.Client/src/client/impl Expand file tree Collapse file tree 1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -701,6 +701,11 @@ public void MainLoopIteration()
701
701
}
702
702
}
703
703
704
+ // socket receive timeout is configured to be 1/2 of the heartbeat timeout
705
+ // and the peer must be considered dead after two subsequent missed heartbeats:
706
+ // terminate after 4 socket timeouts
707
+ private const int SOCKET_TIMEOUTS_TO_CONSIDER_PEER_UNRESPONSIVE = 4 ;
708
+
704
709
protected void HandleIOException ( Exception e )
705
710
{
706
711
// socket error when in negotiation, throw BrokerUnreachableException
@@ -711,9 +716,7 @@ protected void HandleIOException(Exception e)
711
716
throw new BrokerUnreachableException ( cfe ) ;
712
717
}
713
718
714
- // socket receive timeout is configured to be 1/2 of the heartbeat timeout,
715
- // the peer must be considered dead after two subsequent missed heartbeats
716
- if ( ++ m_missedHeartbeats >= 4 )
719
+ if ( ++ m_missedHeartbeats >= SOCKET_TIMEOUTS_TO_CONSIDER_PEER_UNRESPONSIVE )
717
720
{
718
721
var description =
719
722
String . Format ( "Peer missed 2 heartbeats with heartbeat timeout set to {0} seconds" ,
@@ -948,7 +951,7 @@ public void StartHeartbeatTimer()
948
951
if ( Heartbeat != 0 )
949
952
{
950
953
_heartbeatWriteTimer = new Timer ( HeartbeatWriteTimerCallback ) ;
951
- _heartbeatWriteTimer . Change ( m_heartbeatTimeSpan , m_heartbeatTimeSpan ) ;
954
+ _heartbeatWriteTimer . Change ( TimeSpan . FromMilliseconds ( 0 ) , m_heartbeatTimeSpan ) ;
952
955
}
953
956
}
954
957
You can’t perform that action at this time.
0 commit comments