pika.exceptions.ConnectionClosed: (-1, "error(104, 'Connection reset by peer')")

369 views
Skip to first unread message

Manoj G

unread,
Jul 5, 2019, 2:05:31 AM7/5/19
to rabbitmq-users
Hi, 

I have a callback function which process a long message. It takes around 40 to 50 seconds to process the message. 

And then i have the following code in the callback function, 
        if ch.is_open:
           
print "channel is open: ", ch.is_open
           
print "Method delivery tag: ", method.delivery_tag
       
else:
           
print "Channel is closed"
           
        ch
.basic_ack(delivery_tag = method.delivery_tag)

The above code always prints "Connection is open ... ". There are more than 1000 messages in the queue. Need to process all the messages. And it is failing with the following error:
  File "receive_vb.py", line 200, in <module>
    channel
.start_consuming()
 
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1822, in start_consuming
   
self.connection.process_data_events(time_limit=None)
 
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 758, in process_data_events
   
self._dispatch_channel_events()
 
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 521, in _dispatch_channel_events
    impl_channel
._get_cookie()._dispatch_events()
 
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1445, in _dispatch_events
    evt
.body)
 
File "receive_vb.py", line 180, in callback
    ch
.basic_ack(delivery_tag = method.delivery_tag)
 
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 2031, in basic_ack
   
self._flush_output()
 
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 1292, in _flush_output
   
*waiters)
 
File "/usr/lib/python2.7/site-packages/pika/adapters/blocking_connection.py", line 477, in _flush_output
    result
.reason_text)
pika
.exceptions.ConnectionClosed: (-1, "error(104, 'Connection reset by peer')")

If I run without basic_ack, I get the connection reset by peer for some messages randomly (sometime for the second message, sometime 88th message, sometime, 61st message etc. But when i run with basic_ack, fails in first message itself. I tried setting heartbeat_interval parameter to zero and and also to 150, the result is same still. What am I missing here. Can someone help me with this issue? Thanks in Advance.


Regards,
 Manoj G

Michael Klishin

unread,
Jul 31, 2019, 7:04:46 PM7/31/19
to rabbitmq-users
See server fos for clues. One very common reason can be [1]
and then an attempt to use a closed channel [2].


--
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/af1a035a-0ef5-4815-ad33-5e3929312993%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
MK

Staff Software Engineer, Pivotal/RabbitMQ
Reply all
Reply to author
Forward
0 new messages