RabbitMq connection reset by peer

galillei picture galillei · May 9, 2016 · Viewed 11.2k times · Source

I have stainger error with RabbitMQ. I send some information of product threw RabbitMq and Php, but something went wrong. I can send message near one minute after that i had exception "errno=104 Connection reset by peer" . See below:

2016-05-09 08:13:14 Daemon start
2016-05-09 08:13:17 Send to shop-id-1-price
2016-05-09 08:13:21 Send to shop-id-1-price
2016-05-09 08:13:24 Send to shop-id-1-price
2016-05-09 08:13:28 Send to shop-id-1-price
2016-05-09 08:13:32 Send to shop-id-1-price
2016-05-09 08:13:36 Send to shop-id-1-price
2016-05-09 08:13:39 Send to shop-id-1-price
2016-05-09 08:13:43 Send to shop-id-1-price
2016-05-09 08:13:47 Send to shop-id-1-price


  [ErrorException]                                                           
  fwrite(): send of 21 bytes failed with errno=104 Connection reset by peer  


rabbitmq:consumer [-m|--messages [MESSAGES]] [-r|--route [ROUTE]] [-l|--memory-limi
t [MEMORY-LIMIT]] [-d|--debug] [--] <name>

PHP Fatal error:  Uncaught ErrorException: fwrite(): send of 19 bytes failed with e
rrno=32 Broken pipe in /chroot/data/stage/home/html/vendor/videlalva
ro/php-amqplib/PhpAmqpLib/Wire/IO/StreamIO.php:271

version of rabbitmq - 3.6.1, version of php - 7.0.5, version of php-amqp library - "videlalvaro/php-amqplib" : "~2.7

Logs from rabbitmq:

=INFO REPORT==== 9-May-2016::03:36:53 ===
accepting AMQP connection <0.25777.24> (104.207.249.104:38001 -> 104.207.249.104:5672)

=ERROR REPORT==== 9-May-2016::03:37:23 ===
closing AMQP connection <0.25777.24> (104.207.249.104:38001 -> 104.207.249.104:5672):
{writer,send_failed,{error,timeout}}

Answer

Kriszti&#225;n Ferenczi picture Krisztián Ferenczi · Jun 20, 2020

@Gabriele 's link helped to me, here are the details what the issue might be: https://stackoverflow.com/a/36114095/1476819

These two changes solved my problem:

  • Adding this before calling basic_consume. It sets prefetch_count to 1 instead of "infinity".
$channel->basic_qos(null, 1, null);
$channel->basic_consume(...);

I have done these changes at the same time, and now it works with docker.