c# - 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 运行调试器来检查是否有任何问题,因为它总是无法创建我无法继续的连接。在当前调试时,它捕获到None of the specified endpoint were reachable的异常。
在查看内部异常之后,这就是我发现的:
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 offset, Int32 size)
--- End of inner exception stack trace ---
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, 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}
有人介意分享有关如何解决此问题的知识吗?
解决方案
推荐阅读
- php - PHP 解析 XML 内容而不循环超链接
- android - 如何按特定列过滤数据库中的搜索?
- html - 引导元素被彼此吃掉
- java - JSON 输出中的 Jackson:重命名多个用例中的字段(没有单个 JsonProperty)
- groovy - 如何从流程构建器字符串参数中排除 $,以执行 shell 命令
- gnuplot - 如何在gnuplot中并排放置两个带有插图的图?
- node.js - 在 socket.io-client reactjs 中多次发出相同的事件
- python - import cv2 dll load failed: 找不到指定的模块
- exception - 在 Airflow 中传递异常
- javascript - jquery 函数甚至可以从不同的按钮一起执行