简体   繁体   English

Rabbit MQ空闲连接已删除

[英]Rabbit MQ idle connection dropped

I have a .NET windows service running as a consumer/subscriber which is listening to a queue for messages. 我有一个作为使用者/订户运行的.NET Windows服务,正在侦听消息队列。

The windows service is running on the same machine as where rabbit mq server s/w is installed. Windows服务与安装Rabbit mq服务器的软件在同一台计算机上运行。

The queue if idle for 60 minutes results in the connection for it being dropped (i know this as i monitor the UI dashboard) and puts the windows service into a bad state. 如果队列空闲60分钟,则会导致该连接被丢弃(我在监视UI仪表板时就知道了),并将Windows服务置于错误状态。

This is proving to be frustrating to resolve. 事实证明,这令人沮丧。 I have applied heart beat setting on the rabbit mq client but this has had no effect. 我已经在Rabbit mq客户端上应用了心跳设置,但这没有任何效果。

The following error is what i get in the log file when connection drops 连接断开时,我在日志文件中得到以下错误

=ERROR REPORT==== 22-Aug-2017::12:20:29 ===
closing AMQP connection <0.1186.0> ([FE80::C00E:F801:A2A7:8530]:61481 -> 
[FE80::C00E:F801:A2A7:8530]:5672):
missed heartbeats from client, timeout: 30s

Rbbit mq server log file settings: [{rabbit,[ {heartbeat, 60}]}]. rbbit mq服务器日志文件设置:[{rabbit,[{heartbeat,60}]}]。

Client code: 客户代码:

var connectionFactory = new ConnectionFactory
        {
            HostName = hostName,
            UserName = userName,
            Password = password,
            RequestedHeartbeat = heartBeat,
            AutomaticRecoveryEnabled = true,
            NetworkRecoveryInterval = TimeSpan.FromSeconds(numberOfSecondsInterval),
            RequestedConnectionTimeout = RequestedConnectionTimeoutInMiliseconds
        };

        if (port > 0)
            connectionFactory.Port = port;

        var connection = connectionFactory.CreateConnection();

        var model = connection.CreateModel();

        model.BasicQos(prefetchSize: 0, prefetchCount: 1, global: false); 

        return new Tuple<IConnection, IModel>(connection, model);

heartbeat value above is set to 30 seconds, 上面的心跳值设置为30秒,

network recovery value is set to 10 seconds & 网络恢复值设置为10秒&

request connection time out is set to 2 seconds 请求连接超时设置为2秒

i don't know what else i'm missing here in terms of configuration?? 我不知道在配置方面我还缺少什么?

The server where above is running from is Windows 2012 R2 上面运行的服务器是Windows 2012 R2

Basically i'm expecting that to see the connections remain in place always regardless of idle time. 基本上,我期望无论空闲时间如何,连接始终保持在原位。

Is there a Windows OS level TCP keep-alive setting i need to make sure is in place as well? 我是否需要确保还安装了Windows操作系统级别的TCP保持活动设置?

Rabbit MQ version is 3.6.8 Rabbit MQ版本是3.6.8

tearing my hair out on this one so any pointers greatly appreciated 把我的头发扯掉,所以任何指针都非常感谢

I managed to successfully stop the idle connections from dropping (after 60 mins) on RabbitMQ server by applying the re-connect logic that was referenced in this SO post . 通过应用此SO post中引用的重新连接逻辑,我设法成功阻止了RabbitMQ服务器上的空闲连接断开(60分钟后)

To note: The answer was updated to state that the latest version of RabbitMQ client has auto connection recovery enabled so manual re-connection logic should not be needed. 注意:答案已更新为最新版本的RabbitMQ客户端已启用自动连接恢复,因此不需要手动重新连接逻辑。 This was not true in my case as i had applied these settings already but i still saw the connections dropping after 60 minutes idle time. 在我的情况下,这不是正确的,因为我已经应用了这些设置,但是在60分钟的空闲时间后,我仍然看到连接断开。 The client and the server in my scenario are on the same machine. 我的方案中的客户端和服务器位于同一台计算机上。

If anyone by any chance knows where the 60 minutes idle time setting is coming from i would be grateful, i scanned all the rabbitmq config settings and could not find anything related to it. 如果有人偶然知道60分钟空闲时间设置来自何处,我将不胜感激,我扫描了所有Rabbitmq配置设置,但未找到任何与之相关的信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM