简体   繁体   English

AMQP - 连接超时

[英]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. ConnectionReadWrite的默认超时时间为 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.上面的代码将ConnectionReadWrite超时设置为 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.

相关问题 PHPMailer连接超时 - PHPMailer connection timed out 检查“连接超时” - Check for a 'Connection timed out' 与mysql的连接超时 - Connection to mysql timed out AsyncTask上的连接超时 - Connection timed out on AsyncTask 在类扩展上连接超时 - Connection timed out On Class Extend 如果连接超时则重定向 - Redirect if connection has timed out Google SMTP连接超时 - Google SMTP connection timed out 连接超时-Db-Codeigniter - Connection Timed Out - Db - Codeigniter iframe 横幅: <!--? if connection timed out then</div--><div id="text_translate"><p> 在我的站点中,我使用 iframe 来显示来自其他站点的横幅。 问题是,其他站点的连接很少有问题。 现在偏离了那个“不那么频繁”的时间,空帧会出现,这不好。 我想要的是某种 php if..else 条件语句,可以将其重定向到其他横幅。 也许(逻辑上)它会是这样的:</p><pre> &lt;?php $iframe = the iframe url; $banner = the local banner url; if ($iframe connection timed out) {$banner;}?&gt;</pre><p> 我是一个 100% 的菜鸟,所以请帮助 p</p></div> - iframe banner: <? if connection timed out then 通过数据库连接获取连接超时 - Getting connection timed out with DB connection
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM