兔子连接。从未收到启动,可能是由于网络超时.NET Web应用
我正在尝试获取一个.NET 4.7.2 Web应用程序,以连接到(Windows)Docker容器中运行的RabbitMQ服务器(与Web应用程序运行的同一台计算机上)。
更新:使用RabbitMQ的非docker版本也不能解决问题。控制台连接到非docker rabbitmq并可以发布消息,但是.NET 4.7.2 Web应用程序仍然失败。
我正在使用rabbitmq.client 6.2.4(vmware),并带有以下连接代码:
ConnectionFactory connectionFactory = new ConnectionFactory();
Uri uri = new Uri("amqp://dan:dan@localhost:5672/");
connectionFactory.Uri = uri;
var theConnection = connectionFactory.CreateConnection();
(请注意,我也尝试了相同的结果:
var factory = new ConnectionFactory() { HostName = "localhost", Port = 5672, VirtualHost = "/", UserName = "dan", Password = "dan" };
using (var connection = factory.CreateConnection())
)
用户 dan 作为管理员存在,并且具有虚拟主机的权利。
我收到以下错误:
{"None of the specified endpoints were reachable"}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146232800
HelpLink: null
InnerException: {"connection.start was never received, likely due to a network timeout"}
Message: "None of the specified endpoints were reachable"
Source: "RabbitMQ.Client"
StackTrace: " at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)\r\n at XXXX.Common.BackgroundSubmit.SubmitBackgroundProcess.<>c.<SubmitJob>b__0_0(String connectionURI) in C:\\XXXX.Common\\BackgroundSubmit\\BackgroundSubmitProcess.cs:line 71"
TargetSite: {RabbitMQ.Client.IConnection CreateConnection(RabbitMQ.Client.IEndpointResolver, System.String)}
兔子log报告此活动:
2022-05-18 02:18:59.346295+00:00 [info] <0.1164.0> accepting AMQP connection <0.1164.0> (172.19.0.1:55538 -> 172.19.0.2:5672)
2022-05-18 02:18:59.443173+00:00 [warning] <0.1164.0> closing AMQP connection <0.1164.0> (172.19.0.1:55538 -> 172.19.0.2:5672):
2022-05-18 02:18:59.443173+00:00 [warning] <0.1164.0> client unexpectedly closed TCP connection
我创建了一个小的控制台应用程序正常运行 - 它可以连接(随后向队列产生消息)
。 程序没有。
Web应用
https://stackoverflow.com/questions/68011963/factory-createconnection-generates-a-none-of-the-specified-endpoints-were-reac
连接但 所有引用的项目,他们
也尝试使用 rabbitmq_localdev 作为URI中的兔子宿主名称。
任何建议将不胜感激!
谢谢,
d
这是码头组合的.yaml,如果有帮助:
version: "3.2"
services:
rabbitmq:
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
ports:
- 5672:5672
- 15672:15672
# Expose 15672 for the management console, localhost:15672, guest/guest
# Expose 5672 for the qmpq port
# https://stackoverflow.com/questions/30747469/how-to-add-initial-users-when-starting-a-rabbitmq-docker-container
hostname: rabbitmq_localdev
volumes:
- ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/
- ~/.docker-conf/rabbitmq/log/:/var/log/rabbitmq
networks:
- rabbitmq_go_net
networks:
rabbitmq_go_net:
driver: bridge
I am trying to get a .Net 4.7.2 web application to connect to a RabbitMQ server running in a (Windows) Docker container (on the same machine as the web app is running in).
UPDATE: Using a non-Docker version of RabbitMQ does not solve the problem either. The console connects to the non-Docker RabbitMQ and can publish a message, but the .Net 4.7.2 web app still fails.
I am using the RabbitMQ.Client 6.2.4 (VMWare) with the following connection code:
ConnectionFactory connectionFactory = new ConnectionFactory();
Uri uri = new Uri("amqp://dan:dan@localhost:5672/");
connectionFactory.Uri = uri;
var theConnection = connectionFactory.CreateConnection();
(Note I have also tried with the same results:
var factory = new ConnectionFactory() { HostName = "localhost", Port = 5672, VirtualHost = "/", UserName = "dan", Password = "dan" };
using (var connection = factory.CreateConnection())
)
User dan exists as an administrator and has rights to the virtual host.
I am receiving the following error:
{"None of the specified endpoints were reachable"}
Data: {System.Collections.ListDictionaryInternal}
HResult: -2146232800
HelpLink: null
InnerException: {"connection.start was never received, likely due to a network timeout"}
Message: "None of the specified endpoints were reachable"
Source: "RabbitMQ.Client"
StackTrace: " at RabbitMQ.Client.ConnectionFactory.CreateConnection(IEndpointResolver endpointResolver, String clientProvidedName)\r\n at XXXX.Common.BackgroundSubmit.SubmitBackgroundProcess.<>c.<SubmitJob>b__0_0(String connectionURI) in C:\\XXXX.Common\\BackgroundSubmit\\BackgroundSubmitProcess.cs:line 71"
TargetSite: {RabbitMQ.Client.IConnection CreateConnection(RabbitMQ.Client.IEndpointResolver, System.String)}
The RabbitMQ log reports this activity:
2022-05-18 02:18:59.346295+00:00 [info] <0.1164.0> accepting AMQP connection <0.1164.0> (172.19.0.1:55538 -> 172.19.0.2:5672)
2022-05-18 02:18:59.443173+00:00 [warning] <0.1164.0> closing AMQP connection <0.1164.0> (172.19.0.1:55538 -> 172.19.0.2:5672):
2022-05-18 02:18:59.443173+00:00 [warning] <0.1164.0> client unexpectedly closed TCP connection
I created a small console application and that application works fine - it can connect (and subsequently produce a message to a queue). This console application is .NET 6.0.
I have tried using the actual IP address of my machine as well as 127.0.0.1 and the console connects but the web app does not.
I looked at several tickets and thought maybe this was a good lead:
https://stackoverflow.com/questions/68011963/factory-createconnection-generates-a-none-of-the-specified-endpoints-were-reac
this said make sure that System.Threading.Tasks.Extension, System.Threading.Channels and System.Memory are all the same versions in all referenced projects, and they are.
Also tried using rabbitmq_localdev as the rabbit host name in the URI.
Any suggestions would be greatly appreciated!
Thanks,
D
Here is the docker-compose .yaml if it helps:
version: "3.2"
services:
rabbitmq:
image: rabbitmq:3-management-alpine
container_name: 'rabbitmq'
ports:
- 5672:5672
- 15672:15672
# Expose 15672 for the management console, localhost:15672, guest/guest
# Expose 5672 for the qmpq port
# https://stackoverflow.com/questions/30747469/how-to-add-initial-users-when-starting-a-rabbitmq-docker-container
hostname: rabbitmq_localdev
volumes:
- ~/.docker-conf/rabbitmq/data/:/var/lib/rabbitmq/
- ~/.docker-conf/rabbitmq/log/:/var/log/rabbitmq
networks:
- rabbitmq_go_net
networks:
rabbitmq_go_net:
driver: bridge
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我会重新阐述接受的答案。
如果您在库项目中具有
RabbitMQ
客户主要项目(MVC项目,工作,WCF服务等)。这将解决问题。I'll rephrase the accepted answer.
If you have a
RabbitMQ
client in the library project, add the reference of theRabbitMQ.Client
Nuget package also to the root of the main project (MVC project, Job, WCF service, e.t.c). This will resolve the issue.对于那些将来降落在这里的人,我能够解决这个问题。
我的解决方案有多个项目。具有RabbitMQ连接功能的MVC项目具有RabbitMq.Client作为Nuget软件包,但另一个项目没有。我通过Nuget向另一个项目添加了RabbitMq。解决问题。
For those landing here in the future, I was able to resolve this.
My solution had multiple projects. The MVC project that had the RabbitMQ connectivity work in it had RabbitMQ.Client as a NuGet package, but the other project did not. I added RabbitMQ.Client to the other project via NuGet and it solved the problem.
我在WebAPI 4.7.2应用程序上也遇到了同样的问题。在花了很多小时来解决它之后,对我有用的东西降低了'system.luntime.compilerservices.unsafe'的软件包从6.0.0版本中降至4.5.3。
I had the same problem with a WebApi 4.7.2 application. After spending a lot of hours trying to solve it, what worked for me was downgrading the 'System.Runtime.CompilerServices.Unsafe' package from version 6.0.0 to 4.5.3.