通过对等方重置RabbitMq连接

gal*_*lei 5 php rabbitmq php-amqplib

我在RabbitMQ上出现了染色错误。我发送了一些关于RabbitMq和Php的产品信息,但是出了点问题。我可以在异常“ errno = 104对等重置连接”之后的一分钟后发送消息。见下文:

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
Run Code Online (Sandbox Code Playgroud)

版本的Rabbitmq-3.6.1,版本的php-7.0.5,版本的php-amqp库-“ videlalvaro / php-amqplib”:“〜2.7

来自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}}
Run Code Online (Sandbox Code Playgroud)

Kri*_*czi 2

@Gabriele 的链接对我有帮助,以下是问题可能是什么的详细信息:https ://stackoverflow.com/a/36114095/1476819

这两个更改解决了我的问题:

  • 在调用之前添加此内容basic_consume。它设置prefetch_count1而不是“无穷大”。
$channel->basic_qos(null, 1, null);
$channel->basic_consume(...);
Run Code Online (Sandbox Code Playgroud)

我同时完成了这些更改,现在它可以与 docker 一起使用。