[英]AMQP - connection timed out
I receive an error, when trying to receive answer from RabbitMQ.尝试从 RabbitMQ 接收答案时收到错误消息。
2015-07-03 09:31:12 [10.1.101.55][-][-][error][PhpAmqpLib\Exception\AMQPTimeoutException] exception 'PhpAmqpLib\Exception\AMQPTimeoutException' with message 'The connection timed out after 30 sec while awaiting incoming data' in /opt/www/site.ll/vendor/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php:130
Stack trace:
#0 /opt/www/site.ll/vendor/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php(147): PhpAmqpLib\Wire\AMQPReader->wait()
#1 /opt/www/site.ll/vendor/php-amqplib/PhpAmqpLib/Wire/AMQPReader.php(105): PhpAmqpLib\Wire\AMQPReader->rawread(7)
#2 /opt/www/site.ll/vendor/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(528): PhpAmqpLib\Wire\AMQPReader->read(7)
#3 /opt/www/site.ll/vendor/php-amqplib/PhpAmqpLib/Connection/AbstractConnection.php(568): PhpAmqpLib\Connection\AbstractConnection->wait_frame(30)
#4 /opt/www/site.ll/vendor/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(198): PhpAmqpLib\Connection\AbstractConnection->wait_channel(1, 30)
#5 /opt/www/site.ll/vendor/php-amqplib/PhpAmqpLib/Channel/AbstractChannel.php(332): PhpAmqpLib\Channel\AbstractChannel->next_frame(30)
When I trying to receive answer from my local pc it works, but on production server - not.当我试图从我的本地电脑接收答案时,它可以工作,但在生产服务器上 - 不是。
Why, and how I can fix it.为什么,以及我如何解决它。
Thanks!谢谢!
The deafult timeouts for Connection
, Read
and Write
is 3s. Connection
、 Read
和Write
的默认超时时间为 3 秒。 In the development, your requests process too faster than production, so you can't see this error message in the development.在开发中,您的请求处理速度比生产快,因此您在开发中看不到此错误消息。
If you need a greater timeout (as me), you can set it when you create an instance of AMQPStreamConnection
:如果您需要更大的超时(如我),您可以在创建
AMQPStreamConnection
实例时设置它:
$connection = new AMQPStreamConnection(
'localhost',
5672,
'guest',
'guest',
'/',
false,
'AMQPLAIN',
null,
'en_US',
30, //Connection Timeout
30 // Read/Write Timeout
);
The above code set the Connection
, Read
and Write
timeouts to 30s which is reasonable in my case.上面的代码将
Connection
、 Read
和Write
超时设置为 30 秒,这对我来说是合理的。
Make sure the correct port is set.确保设置了正确的端口。 Default is 5672 (not 15672 which is web interface).
默认值为 5672(不是 Web 界面的 15672)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.