简体   繁体   English

当客户端花费60秒以上的时间来确认消息时,Rabbitmq服务器将断开连接

[英]Rabbitmq server drops connection when client takes more than 60 seconds to acknowledge a message

I am currently using EventingBasicConsumer from RabbitMQClient.dll C# client, we spawn a different thread to handle each message that is delivered to the consumer. 我目前正在使用RabbitMQClient.dll C#客户端中的EventingBasicConsumer,我们产生了一个不同的线程来处理传递给使用者的每条消息。

We encountered a strange behavior, the RabbitMQ server closes connections at times with the error missed heartbeats from client, timeout: 60s . 我们遇到了一个奇怪的行为,RabbitMQ服务器有时会关闭连接,而missed heartbeats from client, timeout: 60s错误的missed heartbeats from client, timeout: 60s Few moments later the client reports an error saying Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Library, code=541 . 片刻之后,客户端报告一个错误,提示Already closed: The AMQP operation was interrupted: AMQP close-reason, initiated by Library, code=541 I also see this error client unexpectedly closed TCP connection happening more frequently. 我还看到此错误client unexpectedly closed TCP connection频率更高。

In some situations the clients may take more than 60 seconds to process one job request and this error happens under such conditions. 在某些情况下,客户可能需要60秒钟以上的时间来处理一个作业请求,并且在这种情况下会发生此错误。

Is it required that a job be processed within 60 seconds ?, because for our process this can vary between 30 seconds to 5 minutes. 是否需要在60秒内处理作业?因为对于我们的处理,这可能在30秒到5分钟之间变化。

RabbitMQ server: 3.6.6 RabbitMQ.Client.dll (C# client): RabbitMQ.Client.4.1.1 RabbitMQ服务器:3.6.6 RabbitMQ.Client.dll(C#客户端):RabbitMQ.Client.4.1.1

Any insight into this issue is greatly appreciated. 非常感谢您对此问题的见解。

I used to run much longer jobs (minutes) with EasyNetQ . 我曾经使用EasyNetQ运行更长的工作(几分钟)。 It's more high-level client that wraps RabbitMQ.Client . 包装RabbitMQ.Client的是更高级的客户端。

For me, the reason of these errors is something like Evk wrote in this comment . 对我来说,这些错误的原因类似于Evk在此评论中写道。 I would try EasyNetQ as it likely has fetching of messages decoupled from the handling process. 我会尝试EasyNetQ,因为它可能已获取与处理过程分离的消息。

You can increase the TTL timeout in RabbitMq both per queue and per message 您可以为每个队列和每个消息增加RabbitMq中的TTL超时

IBasicProperties mqProps = model.CreateBasicProperties();
mqProps.ContentType = "text/plain";
mqProps.DeliveryMode = 2;
mqProps.Expiration = "300000" 

model.BasicPublish(exchangeName,
                   routingKey, mqProps,
                   messageBodyBytes);

Documentaion is at https://www.rabbitmq.com/ttl.html 文档位于https://www.rabbitmq.com/ttl.html

But I think you're better off by rewriting it to Async pattern for the actual processing of the message. 但是我认为最好将其重写为异步模式以进行消息的实际处理。

This might give you inspiration for doing async message processing with RabbitMq 这可能会给您启发,使用RabbitMq进行异步消息处理

https://codereview.stackexchange.com/questions/42836/listen-to-multiple-rabbitmq-queue-by-task-and-process-the-message https://codereview.stackexchange.com/questions/42836/listen-to-multiple-rabbitmq-queue-by-task-and-process-the-message

And in this question there are quite allot of information too on async message consumption. 在这个问题上,异步消息的使用也分配了很多信息。

multi-threading based RabbitMQ consumer 基于多线程的RabbitMQ使用者

暂无
暂无

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

相关问题 在客户端已完全处理消息时进行确认。 的RabbitMQ - Acknowledge when the client has completely processed the message. Rabbitmq 任务开始运行需要几秒钟的时间 - It takes more than a few seconds for a task to start running MassTransit Producer花费60秒来消费事件 - MassTransit Producer takes 60 seconds to Consume an event 当在同一数据库表上同时运行多个60个更新进程时,SQL Server 2014返回死锁(错误1205) - SQL Server 2014 returns deadlock (error 1205) when run simultaneously more than 60 updating processes on the same DB table C#套接字服务器无法多次从同一客户端连接接收数据 - C# sockets server unable to receive data from same client connection more than once 客户端无法从服务器(C#)读取多个消息 - Client can't read more than one message from server (C#) 在Android上使用HttpClient进行的第一个请求花费了超过45秒的时间,之后不到第二秒 - First request with HttpClient on Android takes more than 45 seconds, after that less than second 部署在 linux 服务器上时,mongodb 客户端连接在 .net 核心中需要 15 分钟,但部署在 Z05F45137ED8AA208B 上时同样工作正常 - mongodb client connection takes 15 minutes in .net core when deployed on linux server but the same working fine when deployed on windows server 服务器不会响应多于一条消息 - Server Will Not Respond To More Than One Message 为什么在 DirectoryEntry 上调用 SetPassword 需要 60 秒才能成功? - Why does calling SetPassword on a DirectoryEntry takes 60 seconds to succeed?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM