laravel RabbitMQ 错误:fwrite():发送 12 个字节失败,errno=104 Connection reset by peer
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29653843/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
RabbitMQ Error: fwrite(): send of 12 bytes failed with errno=104 Connection reset by peer
提问by Marwan
I'm using the RabbitMQ Library videlalvaro/php-amqplibinside a Laravel 4.2application and I've started getting the following error:
我使用的是RabbitMQ的图书馆videlalvaro / PHP-amqplib一个内部Laravel 4.2应用程序,我已经开始收到以下错误:
fwrite(): send of 12 bytes failed with errno=104 Connection reset by peer"
Can anyone suggest anything that might be causing this?
任何人都可以提出任何可能导致这种情况的建议吗?
回答by Limon Monte
"Connection reset by peer" is the TCP/IP equivalent of slamming the phone back on the hook. It's more polite than merely not replying, leaving one hanging. But it's not the FIN-ACK expected of the truly polite TCP/IP converseur. (From other SO answer)
“由对等方重置连接”是 TCP/IP 等价物,相当于将电话重新挂断。这比仅仅不回答、留下一个悬而未决更有礼貌。但这不是真正礼貌的 TCP/IP 对话者所期望的 FIN-ACK。(来自其他 SO 答案)
So you can't do anything about it, it is the issue of the server.
所以你无能为力,这是服务器的问题。
But you could use try .. catch
block to handle that exception:
但是您可以使用try .. catch
block 来处理该异常:
try {
$msg = new AMQPMessage('Hello World!');
$channel->basic_publish($msg, '', 'hello');
} catch (Exception $e) {
// handle exception
}
回答by Kush
I had the same issue. Setting prefetch count to 1 is working for me as I don't care little performance tradeoff with stability.
我遇到过同样的问题。将预取计数设置为 1 对我有用,因为我不关心性能与稳定性的折衷。
$channel->basic_qos(0, 1, false);
syntax:
句法:
basic_qos($prefetch_size, $prefetch_count, $a_global);