BlockingConnection hearbeat
See original GitHub issueHello, I need your help. Cannot figure out solution. I’m using Rabbitmq docker container with my python app.
About 10 min after running I having exception in my app:
pika.exceptions.ConnectionClosed: (-1, 'EOF')
Following log in rabbitmq docker:
2018-05-27 11:05:25.296 [warning] <0.1795.0> closing AMQP connection <0.1795.0> (172.18.0.1:58040 -> 172.18.0.2:5672):
missed heartbeats from client, timeout: 60s
Here is my producer code:
class Producer(object):
EXCHANGE_TYPE = "direct"
EXCHANGE_DURABLE = True
def __init__(self, url, exchange):
self._connection = pika.BlockingConnection(pika.URLParameters(url))
self._channel = self._connection.channel()
self._exchange = exchange
self._channel.exchange_declare(
exchange=self._exchange,
exchange_type=self.EXCHANGE_TYPE,
durable=self.EXCHANGE_DURABLE
)
def publish(self, route, data):
self._channel.basic_publish(exchange=self._exchange, routing_key=route, body=data)
def close(self):
self._channel.close()
self._connection.close()
url = ‘amqp://guest:guest@’+ args.rmq +‘:5672/%2F?heartbeat=0’ exchange = “my_exchange”
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (7 by maintainers)
Top Results From Across the Web
Ensuring well-behaved connection with heartbeat and ... - Pika
A blocked connection may last for an indefinite period of time, stalling the connection and possibly resulting in a hang (e.g., in BlockingConnection)...
Read more >Keep pika BlockingConnection alive without disabling heartbeat
The only solution is to send heartbeat frames periodically. When using a BlockingConnection , you have to call the process_data_events ...
Read more >Impossible to disable heartbeats with BlockingConnection #965
However when trying to set heartbeat=0 in the ConnectionParameters, the server value is always respected. Example code to reproduce with default ...
Read more >Detecting Dead TCP Connections with Heartbeats ... - RabbitMQ
The heartbeat timeout value defines after what period of time the peer TCP connection should be considered unreachable (down) by RabbitMQ and client...
Read more >Heartbeat with BlockingConnection - Google Groups
I'm trying out heartbeat with BlockingConnection. · This is the code for the connection: · params = ConnectionParameters(host=self. · self. · After connecting,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@farrukh-okhunov I am able to reproduce what you describe without using docker.
Please see the changes I made in this commit which shows how to ensure heartbeats are processed while using
BlockingConnection
.In your code, you should enable heartbeats, and use
process_data_events()
periodically to ensure they are processed. Or, you could use the asynchronous publisher code here as a starting point, as it will periodically send heartbeats.Here is a summary of what I think is affecting you:
0.12.0b3
, so I would like you to test with that version.SelectConnection
or modify your code in a manner to what I have done here to ensure that heartbeats are processed.I am going to close this issue now but please feel free to comment and re-open it if you have further questions or find something new. Thanks again for patiently providing the information I requested.
Thanks for providing all that information. This issue may be related to #1055.
Fixing issues that only arise in docker are not as high priority as other issues. I suggest searching docker issues or the internet for other abrupt connection closure issues - maybe there is a docker setting that needs to be adjusted?
Just as a reminder, Pika is maintained by volunteers on their spare time.