import pika
from time import sleep
connection = pika.BlockingConnection()
channel = connection.channel()
channel.queue_declare(queue='log_queue')
channel.basic_publish(exchange='', routing_key='log_queue', body='Hello')
sleep(180)
channel.basic_publish(exchange='', routing_key='log_queue', body='Hello')
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/rabbitmq-users/af0243ef-d18d-4180-ae96-dde9ca069515%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
Also this is a blocking connection.so there is no loop. I have found if I set heartbeat to zero then it works. Perhaps there is better way using a select connection?
On Fri, 28 Jun 2019, 23:52 Luke Bakken, <lba...@pivotal.io> wrote:
Hello,--When you sleep, you block Pika's I/O loop and thus you block heartbeats. RabbitMQ expects heartbeats every 60 seconds. By sleeping 180 seconds, RabbitMQ thinks the connection is dead and closes it.So, don't block the I/O loop.Thanks,Luke
On Friday, June 28, 2019 at 12:53:30 PM UTC-7, simon mackenzie wrote:I am trying to send log messages. This works fine and I can see the messages on the consumer console. However the producer automatically disconnects after about 180 seconds. So when I am working in a jupyter notebook I just stop for 3 minutes and the logs no longer work. Presumably there is a timeout setting somewhere but where?This is example producer code.import pika
from time import sleep
connection = pika.BlockingConnection()
channel = connection.channel()
channel.queue_declare(queue='log_queue')
channel.basic_publish(exchange='', routing_key='log_queue', body='Hello')
sleep(180)
channel.basic_publish(exchange='', routing_key='log_queue', body='Hello')First message received fine. Second messageStreamLostError: Stream connection lost: ConnectionResetError(10054, 'An existing connection was forcibly closed by the remote host', None, 10054, None)
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-users+unsubscribe@googlegroups.com.
To post to this group, send email to rabbitmq-users@googlegroups.com.