PHP Rabbitmq 报错Broken pipe

Posted php-linux

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP Rabbitmq 报错Broken pipe相关的知识,希望对你有一定的参考价值。

fwrite(): send of 13 bytes failed with errno=32 Broken pipe

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

 

用 rabbitmq 做消息队列时报上面的错误,当消费队列一启动,Unacked 瞬间达到好几百。经查:RabbitMQ服务器在短时间内发送大量的消息给Consumer,如果你没有来得及Ack的话,那么服务端会积压大量的UnAcked消息,而Consumer如果来不急处理也会处于假死或程序崩溃。

后果就是Consmer崩溃后,UnAcked消息又ReQueue不断消耗MQ的资源

 

解决方案:

技术图片
$connection = new AMQPStreamConnection(HOST, PORT, USER, PASS, VHOST);

$channel = $connection->channel();

$channel->queue_declare(‘qos_queue‘, false, true, false, false);

$channel->basic_qos(null, 10, null); //加上这个就好了 这个10 就是Unacked 里面的值,表示预先取出多少值来消费  prefetch_count
技术图片

 

以上是关于PHP Rabbitmq 报错Broken pipe的主要内容,如果未能解决你的问题,请参考以下文章

PHP系列 | PDO::prepare(): send of 68 bytes failed with errno=32 Broken pipe

golang服务报错: write: broken pipe

linux 下 tomcat 运行报错 Broken pipe

C++运行报错:what(): std::future_error: Broken promise

C++运行报错:what(): std::future_error: Broken promise

解决Linux下ssh登录后出现 报错 Write failed: Broken pipe 的方法