c# - 指定的端点均不可到达

标签 c# .net rabbitmq

从 .net 应用程序发布消息时,rabbitmq 中存在间歇性问题。它在系统中产生大量噪音。 我已尝试使用谷歌搜索,但找不到问题的根本原因。

这是我在应用程序日志中看到的错误,

None of the specified endpoints were reachable
Endpoints attempted:
------------------------------------------------
endpoint=amqp-0-9://localhost:5672, attempts=1
System.TimeoutException: Connection to amqp-0-9://localhost:5672 timed out
   at RabbitMQ.Client.Impl.SocketFrameHandler_0_9.Connect(TcpClient socket, AmqpTcpEndpoint endpoint, Int32 timeout)
   at RabbitMQ.Client.Impl.SocketFrameHandler_0_9..ctor(AmqpTcpEndpoint endpoint, ObtainSocket socketFactory, Int32 timeout)
   at RabbitMQ.Client.Framing.Impl.v0_9_1.ProtocolBase.CreateFrameHandler(AmqpTcpEndpoint endpoint, ObtainSocket socketFactory, Int32 timeout)
   at RabbitMQ.Client.ConnectionFactory.FollowRedirectChain(Int32 maxRedirects, IDictionary`2 connectionAttempts, IDictionary`2 connectionErrors, AmqpTcpEndpoint[]& mostRecentKnownHosts, AmqpTcpEndpoint endpoint)
================================================
Stack trace:
   at RabbitMQ.Client.ConnectionFactory.CreateConnection(Int32 maxRedirects)
   at RabbitMQ.Client.ConnectionFactory.CreateConnection()

最佳答案

我通过使 RabbitMQ Connection 对象成为单例来确保重用连接而不是每次都建立新连接,从而解决了这个问题。

关于c# - 指定的端点均不可到达,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32432018/

相关文章:

c# - 使用 "as"关键字转换对象返回 null

c# - UnityContainer.Resolve 比 Activator.CreateInstance 有什么优势?

arduino - RabbitMQ 与 Arduino Uno

.net - 在NServiceBus中为RabbitMQ交换MSMQ

java - 获取以某种方式使用 RabbitMQ 中给定队列的 channel

c# - 同时使用 Tab 的 ReSharper 和 GitHub Copilot 自动完成之间的冲突

c# - 从经典和 DDD 角度来看存储库的投影

C#技巧——通过字符串获取常量值

.net - 将一个程序集安装到 GAC 上,用于 mono/.NET

c# - 正则表达式未使用 Unicode 字符范围