factory.CreateConnection() 生成 None 个指定端点可达;
factory.CreateConnection() generates a None of the specified endpoints were reachable;
我们在 IIS 8 下的 ASP.NET Web 应用程序 运行 中有一个简单的 RabbitMQ .NET 客户端。我们不使用任何 SSL,连接代码也很简单。
var factory = new ConnectionFactory()
{
HostName = hostname,
UserName = username,
Password = password,
VirtualHost = vhost,
Port = 5672
};
var connection = factory.CreateConnection();
最后一行生成以下异常
Exception Occurred
Type: RabbitMQ.Client.Exceptions.BrokerUnreachableException
Message: None of the specified endpoints were reachable
Stack Trace: at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 505
at Org.Prod.Dependency.Concrete.Queuing.RabbitMqProdMessenger.SendMessage[TMessage](String hostname, String username, String password, String vhost, String target, TMessage message, Boolean targetIsExchange)
Source: RabbitMQ.Client
Inner Exception
Type: System.IO.IOException
Message: connection.start was never received, likely due to a network timeout
Stack Trace: at RabbitMQ.Client.Framing.Impl.Connection.StartAndTune() in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 1074
at RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist) in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 707
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh) in /_/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs:line 646
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 495
Source: RabbitMQ.Client
有趣的是,当将相同的代码放入控制台应用程序并将二进制文件发送到应用程序的同一服务器运行时,控制台应用程序可以正常连接并能够发布消息。
Web 应用程序尝试执行与控制台应用程序相同的操作有什么问题?
这是 System.Threading.Tasks.Extensions
的程序集绑定失败,我们的异常记录器没有记录 InnerException
Exception information:
Exception type: FileLoadException
Exception message: Could not load file or assembly 'System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection..ctor(ConnectionFactory factory, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 494
非常糟糕的误导性错误消息。
在我的例子中,我在调用 factory.CreateConnection() 时收到了完全相同的异常;我在依赖于 System.Buffers 4.5.1 的库中使用 RabbitMQ.Client 6.2.1,我的主程序集引用了 System.Buffers 4.4.0,将我的主程序集更新为引用版本 4.5.1 System.Buffers,其中涉及很多其他依赖的 Microsoft。和系统。在我可以删除之前先删除程序集,然后通过 NuGet 包管理器重新添加 System.Buffers 因为这告诉我当我的 .csproj 文件说它引用 4.4.0 时我有 4.5.1。一旦解决了这个参考问题,问题就消失了,我可以连接到 RabbitMQ 服务器。
我们在 IIS 8 下的 ASP.NET Web 应用程序 运行 中有一个简单的 RabbitMQ .NET 客户端。我们不使用任何 SSL,连接代码也很简单。
var factory = new ConnectionFactory()
{
HostName = hostname,
UserName = username,
Password = password,
VirtualHost = vhost,
Port = 5672
};
var connection = factory.CreateConnection();
最后一行生成以下异常
Exception Occurred
Type: RabbitMQ.Client.Exceptions.BrokerUnreachableException
Message: None of the specified endpoints were reachable
Stack Trace: at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 505
at Org.Prod.Dependency.Concrete.Queuing.RabbitMqProdMessenger.SendMessage[TMessage](String hostname, String username, String password, String vhost, String target, TMessage message, Boolean targetIsExchange)
Source: RabbitMQ.Client
Inner Exception
Type: System.IO.IOException
Message: connection.start was never received, likely due to a network timeout
Stack Trace: at RabbitMQ.Client.Framing.Impl.Connection.StartAndTune() in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 1074
at RabbitMQ.Client.Framing.Impl.Connection.Open(Boolean insist) in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 707
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IFrameHandler fh) in /_/projects/RabbitMQ.Client/client/impl/AutorecoveringConnection.cs:line 646
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 495
Source: RabbitMQ.Client
有趣的是,当将相同的代码放入控制台应用程序并将二进制文件发送到应用程序的同一服务器运行时,控制台应用程序可以正常连接并能够发布消息。
Web 应用程序尝试执行与控制台应用程序相同的操作有什么问题?
这是 System.Threading.Tasks.Extensions
的程序集绑定失败,我们的异常记录器没有记录 InnerException
Exception information:
Exception type: FileLoadException
Exception message: Could not load file or assembly 'System.Threading.Channels, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection..ctor(ConnectionFactory factory, String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName) in /_/projects/RabbitMQ.Client/client/api/ConnectionFactory.cs:line 494
非常糟糕的误导性错误消息。
在我的例子中,我在调用 factory.CreateConnection() 时收到了完全相同的异常;我在依赖于 System.Buffers 4.5.1 的库中使用 RabbitMQ.Client 6.2.1,我的主程序集引用了 System.Buffers 4.4.0,将我的主程序集更新为引用版本 4.5.1 System.Buffers,其中涉及很多其他依赖的 Microsoft。和系统。在我可以删除之前先删除程序集,然后通过 NuGet 包管理器重新添加 System.Buffers 因为这告诉我当我的 .csproj 文件说它引用 4.4.0 时我有 4.5.1。一旦解决了这个参考问题,问题就消失了,我可以连接到 RabbitMQ 服务器。