RabbitMQ连接失败异常在生产服务器上

huangapple go评论89阅读模式
英文:

RabbitMq connection failed exception on production server

问题

以下是您要翻译的代码部分:

我有一个基于.NET 4.6.2构建的Windows Forms应用程序。我正在使用以下代码将该应用程序连接到RabbitMQRabbitMQ服务部署在单独的服务器上

var factory = new ConnectionFactory() { HostName = _host, Port = _port, UserName = _userName, Password = _password };
if (_port != 5672){
factory.Ssl.Enabled = true;
factory.Ssl.Version = System.Security.Authentication.SslProtocols.Tls12;
factory.Ssl.CertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };}
Client = factory.CreateConnection();
Channel = Client.CreateModel();

这在生产环境中完全正常工作。最近我们计划发布一个新版本,在该版本中其他组件发生了变化,但此应用程序没有发生变化。然而,当我在生产服务器上运行该应用程序时,它会出现以下异常。

RabbitMQ.Client.Exceptions.BrokerUnreachableException: 无法连接到指定的端点 ---> System.IO.IOException: 由于网络超时,可能未收到connection.start
   RabbitMQ.Client.Framing.Impl.Connection.StartAndTune()
   RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist)
   RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh)
   RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
   --- 内部异常堆栈跟踪的结尾 ---
   RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
   LiveStatisticsBroker.CheckAndUpdateSessionStatus() in LiveStatistics.cs:line 105

代码没有更改,如果我恢复到先前的版本,它可以正常工作。我已经检查了网络连接,即使使用telnet连接服务器IP和端口5671也没有问题。

奇怪的是,如果我将相同的发布版本放在开发服务器上,RabbitMQ可以连接。我们的开发服务器也遵循相同的网络规则。我已经被困在这个问题上一段时间,但没有取得任何成功。

英文:

I have a windows forms application that is built on .NET 4.6.2. I'm connecting the app to rabbitmq using below code. Rabbit mq services are deployed on a separate server.

var factory = new ConnectionFactory() { HostName = _host, Port = _port, UserName = _userName, Password = _password };
if (_port != 5672){
factory.Ssl.Enabled = true;
factory.Ssl.Version = System.Security.Authentication.SslProtocols.Tls12;
factory.Ssl.CertificateValidationCallback = delegate (object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) { return true; };}
Client = factory.CreateConnection();
Channel = Client.CreateModel();

This is working completely fine in production. Now recently we were planning a new release where there were changes in other components but no changes in this app however when I run the app on production server it gives below exception.

RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> System.IO.IOException: connection.start was never received, likely due to a network timeout
   at RabbitMQ.Client.Framing.Impl.Connection.StartAndTune()
   at RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist)
   at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh)
   at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
   --- End of inner exception stack trace ---
   at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)
   at LiveStatisticsBroker.CheckAndUpdateSessionStatus() in LiveStatistics.cs:line 105

There are no changes in the code and if I revert to the previous release it works fine. I have checked network connectivity and there are no issues even if I telnet the server IP and with port 5671 it gets succeeded.

Strange thing is If I place same release on development server rabbitmq gets connected. Our development servers also follow same network rules. I have been stuck on this for some time and couldn't get any success.

答案1

得分: 0

升级 RabbitMq.Client NuGet 包从 6.2.1 到 6.5.0 对我有帮助。System.Memory 也被升级为一个依赖项。

英文:

Upgrading RabbitMq.Client nuget package from 6.2.1 to 6.5.0 did the trick for me. System.Memory was also upgraded as a dependency.

huangapple
  • 本文由 发表于 2023年8月10日 18:50:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/76875032.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定