3

I have a .NET windows service running as a consumer/subscriber which is listening to a queue for messages.

The windows service is running on the same machine as where rabbit mq server s/w is installed.

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.

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.

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}]}].

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,

network recovery value is set to 10 seconds &

request connection time out is set to 2 seconds

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

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?

Rabbit MQ version is 3.6.8

tearing my hair out on this one so any pointers greatly appreciated

4

1 回答 1

1

通过应用此 SO 帖子中引用的重新连接逻辑,我成功地阻止了 RabbitMQ 服务器上的空闲连接断开(60 分钟后)。

注意:答案已更新为声明最新版本的 RabbitMQ 客户端已启用自动连接恢复,因此不需要手动重新连接逻辑。在我的情况下这不是真的,因为我已经应用了这些设置,但我仍然看到连接在 60 分钟空闲时间后下降。我的场景中的客户端和服务器在同一台机器上。

如果有人知道 60 分钟空闲时间设置的来源,我将不胜感激,我扫描了所有 rabbitmq 配置设置,但找不到任何相关内容。

于 2017-08-26T13:07:36.940 回答