Skip to content
Snippets Groups Projects
Commit 321b21b5 authored by Gavin M. Roy's avatar Gavin M. Roy
Browse files

Fix the hearbeat negotiation logic

- If heartbeat is not configured, used the server
- If it is configured and is 0 or the server is 0, turn it off
- Otherwise use the client requested value
parent af7409ca
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -191,7 +191,8 @@ class Channel0(base.AMQPChannel):
:return: int
 
"""
return min(client_value, server_value) or (client_value or server_value)
return min(client_value, server_value) or \
(client_value or server_value)
 
def _on_connection_open_ok(self):
LOGGER.debug('Connection opened')
Loading
Loading
@@ -233,9 +234,13 @@ class Channel0(base.AMQPChannel):
frame_value.frame_max)
self._max_channels = self._negotiate(self._max_channels,
frame_value.channel_max)
if self._heartbeat_interval > 0:
self._heartbeat_interval = self._negotiate(self._heartbeat_interval,
frame_value.heartbeat)
# Properly negotiate the heartbeat interval
if self._heartbeat_interval is None:
self._heartbeat_interval = frame_value.heartbeat
elif self._heartbeat_interval == 0 or frame_value.heartbeat == 0:
self._heartbeat_interval = 0
self.write_frame(self._build_tune_ok_frame())
self.write_frame(self._build_open_frame())
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment