Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server closes after pika.exceptions.StreamLostError: Stream connection lost

Tags:

rabbitmq

I have some images in my queue and I pass each image to my flask server where processing on images is done and a response is received in my rabbitmq server. After receiving response, I get this error "pika.exceptions.StreamLostError: Stream connection lost(104,'Connection reset by peer')". This happens when rabbitmq channel again starts consuming the connection. I don't understand why this happens. Also I would like to restart the server again automatically if this error persists. Is there any way to do that?

like image 566
Fenil Shah Avatar asked Jul 02 '19 19:07

Fenil Shah


2 Answers

Your consume process is probably taking too much time to complete and send Ack/Nack to the server. Therefore, server does not receive heartbeat from your client, and thereby stops from serving. Then, on the client side you receive:

pika.exceptions.StreamLostError: Stream connection lost(104,'Connection reset by peer')

You should see server logs as well. It is probably like this:

missed heartbeats from client, timeout: 60s

See this issue for mor information.

like image 171
mm49307 Avatar answered Nov 03 '22 04:11

mm49307


Do your work on another thread. See this code as an example -

https://github.com/pika/pika/blob/master/examples/basic_consumer_threaded.py


NOTE: the RabbitMQ team monitors the rabbitmq-users mailing list and only sometimes answers questions on StackOverflow.

like image 2
Luke Bakken Avatar answered Nov 03 '22 04:11

Luke Bakken