我设置了 RabbitMQ 以解析来自外部 API 的大约 20.000 个请求,但几分钟后它一直超时.它确实可以正确解析总共 20.000 个请求中的大约 2000 个.
I've set up RabbitMQ in order to parse some 20.000 requests from an external API but it keeps timing out after a few minutes. It does get to correctly parse about 2000 out of the total 20.000 requests.
日志文件说:
=INFO REPORT==== 16-Feb-2016::17:02:50 ===
accepting AMQP connection <0.1648.0> (127.0.0.1:33091 -> 127.0.0.1:5672)
=ERROR REPORT==== 16-Feb-2016::17:03:21 ===
closing AMQP connection <0.1648.0> (127.0.0.1:33091 -> 127.0.0.1:5672):
{writer,send_failed,{error,timeout}}
我已经增加了心跳值,但我无法弄清楚它为什么会超时.配置为:Ubuntu 14.04、NGINX 1.8.1、RabbitMQ 3.6.0
I've already increased the heartbeat value but I cannot figure out why it's timing out. Configuration is: Ubuntu 14.04, NGINX 1.8.1, RabbitMQ 3.6.0
感谢您的宝贵时间和意见!
I'd appreciate your time and input !
我刚刚用python解决了一个类似的问题.在我的例子中,它是通过减少消费者的预取计数来解决的,这样它的接收缓冲区中排队的消息就会更少.
I've just solved a similar problem in python. In my case, it was solved by reducing the prefetch count on the consumer, so that it had fewer messages queued up in its receive buffer.
我的理论是消费者的接收缓冲区已满,然后 RMQ 尝试将一些其他消息写入消费者的套接字,但由于消费者的套接字已满而不能.RMQ 在此套接字上阻塞,最终超时并关闭消费者上的连接.具有较小的预取队列意味着套接字接收缓冲区不会被填满,并且 RMQ 能够写入它试图执行的任何簿记消息,因此不会在其写入时超时,也不会关闭连接.
My theory is that the receive buffer on the consumer gets full, and then RMQ tries to write some other message to the consumer's socket and can't due to the consumer's socket being full. RMQ blocks on this socket, and eventually timeouts and just closes the connection on the consumer. Having a smaller prefetch queue means the socket receive buffer doesn't get filled, and RMQ is able to write whatever bookkeeping messages it was trying to do and so doesn't timeout on its writes nor close the connection.
虽然这只是一个理论,但它似乎在我的测试中成立.
This is just a theory though, but it seems to hold in my testing.
在 Python 中,可以这样设置预取计数:
In Python, setting the prefetch count can be done like so:
subChannel.basicQos(10);
(感谢@shawn-guo 提醒我添加此代码段)
(Thanks to @shawn-guo for reminding me to add this code snippet)
这篇关于RabbitMQ 错误超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!