RabbitMQ C# AMQP 在尝试连接本地主机时被中断

问题描述

您好,我对如何解决这个问题感到困惑。在此之前我已经看过很多线程,但是没有一个能够解决我的问题。

我有一个像这样的基本连接

ConnectionFactory factory = new ConnectionFactory
{
   HostName = "localhost",VirtualHost = "/",Port = 5672,UserName = "guest",Password = "guest",RequestedHeartbeat = TimeSpan.FromSeconds(60)
};

conn = factory.CreateConnection();
channel = conn.CreateModel();

我使用 Visual Studio 运行调试器来检查是否有任何问题,因为它总是无法创建我无法继续的连接。当前调试时,它会捕获指定的端点均不可达的异常。

查看内部异常后,这是我发现的:

The AMQP operation was interrupted: AMQP close-reason,initiated by Library,code=541,text='Unexpected Exception',classId=0,methodId=0,cause=System.IO.IOException: Unable to read data from the transport connection: An existing connection was forcibly closed by the remote host. ---> System.Net.sockets.socketException: An existing connection was forcibly closed by the remote host
   at System.Net.sockets.socket.Receive(Byte[] buffer,Int32 offset,Int32 size,SocketFlags socketFlags)
   at System.Net.sockets.NetworkStream.Read(Byte[] buffer,Int32 size)
   --- End of inner exception stack trace ---
   at System.Net.sockets.NetworkStream.Read(Byte[] buffer,Int32 size)
   at System.IO.BufferedStream.ReadByte()
   at RabbitMQ.Client.Impl.InboundFrame.ReadFrom(Stream reader,Byte[] frameHeaderBuffer) in /_/projects/RabbitMQ.Client/client/impl/Frame.cs:line 222
   at RabbitMQ.Client.Impl.socketFrameHandler.ReadFrame() in /_/projects/RabbitMQ.Client/client/impl/SocketFrameHandler.cs:line 220
   at RabbitMQ.Client.Framing.Impl.Connection.MainLoopIteration() in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 557
   at RabbitMQ.Client.Framing.Impl.Connection.MainLoop() in /_/projects/RabbitMQ.Client/client/impl/Connection.cs:line 499 

据我所知,这是无法与rabbitMQ建立连接的问题。我已经通过防火墙打开了端口,但它仍然弹出相同的错误,所以我不知道我应该做什么。

我也检查了日志以确保,但我不明白发生了什么,因为我还是 rabbitMQ 的新手

2021-04-06 16:17:41.864 [info] <0.1808.0> accepting AMQP connection <0.1808.0> ([::1]:52393 -> [::1]:5672)
2021-04-06 16:17:43.220 [error] <0.530.0> Could not find handle.exe,please install from sysinternals
2021-04-06 16:17:48.250 [error] <0.530.0> Could not find handle.exe,please install from sysinternals
2021-04-06 16:17:51.864 [error] <0.1808.0> closing AMQP connection <0.1808.0> ([::1]:52393 -> [::1]:5672): {handshake_timeout,frame_header}

有人介意分享有关如何解决此问题的知识吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)