c# - 创建从 .netcore 3.1 到 Amazon MQ (RabbitMQ) 的连接时出错
问题描述
我下面的代码在 .netcore 3.1 中(使用 RabbitMQ.Client 6.1)连接到 AmazonMQ(RabbitMQ)
factory = new ConnectionFactory
{
HostName = "amqps://xxxxxxxxxxxxxxxx.amazonaws.com",
UserName = "username",
Password = "password",
Port = 5671
};
factory.Uri = new Uri(string.Format("{0}:{1}", factory.HostName, factory.Port));
connection = factory.CreateConnection();
我使用自容器发布代码,它在机器(Windows 10)中运行良好,但是当我在 Windows 7 中运行它时,出现此错误。
[ERR] Could not make connection to RabbitMQ on Amazon MQ
RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable
---> System.AggregateException: One or more errors occurred. (Authentication failed, see inner exception.)
---> System.Security.Authentication.AuthenticationException: Authentication failed, see inner exception.
---> System.ComponentModel.Win32Exception (0x80090302): The function requested is not supported
--- End of inner exception stack trace ---
at System.Net.Security.SslStream.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, ExceptionDispatchInfo exception)
at System.Net.Security.SslStream.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartSendBlob(Byte[] incoming, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.StartReadFrame(Byte[] buffer, Int32 readBytes, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslStream.PartialFrameCallback(AsyncProtocolRequest asyncRequest)
--- End of stack trace from previous location where exception was thrown ---
at System.Net.Security.SslStream.ThrowIfExceptional()
at System.Net.Security.SslStream.InternalEndProcessAuthentication(LazyAsyncResult lazyResult)
at System.Net.Security.SslStream.EndProcessAuthentication(IAsyncResult result)
at System.Net.Security.SslStream.EndAuthenticateAsClient(IAsyncResult asyncResult)
at System.Net.Security.SslStream.<>c.<AuthenticateAsClientAsync>b__64_2(IAsyncResult iar)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at RabbitMQ.Client.Impl.SslHelper.<>c__DisplayClass2_0.<TcpUpgrade>b__0(SslOption opts)
at RabbitMQ.Client.Impl.SslHelper.TcpUpgrade(Stream tcpStream, SslOption options)
at RabbitMQ.Client.Impl.SocketFrameHandler..ctor(AmqpTcpEndpoint endpoint, Func`2 socketFactory, TimeSpan connectionTimeout, TimeSpan readTimeout, TimeSpan writeTimeout)
at RabbitMQ.Client.Framing.Impl.IProtocolExtensions.CreateFrameHandler(IProtocol protocol, AmqpTcpEndpoint endpoint, Func`2 socketFactory, TimeSpan connectionTimeout, TimeSpan readTimeout, TimeSpan writeTimeout)
at RabbitMQ.Client.ConnectionFactory.CreateFrameHandler(AmqpTcpEndpoint endpoint)
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
--- End of inner exception stack trace ---
at RabbitMQ.Client.EndpointResolverExtensions.SelectOne[T](IEndpointResolver resolver, Func`2 selector)
at RabbitMQ.Client.Framing.Impl.AutorecoveringConnection.Init(IEndpointResolver endpoints)
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 RabbitMQ.Client.ConnectionFactory.CreateConnection(String clientProvidedName)
at RabbitMQ.Client.ConnectionFactory.CreateConnection()
经过一段时间挖掘错误并搜索并尝试(例如关闭防火墙,为我的应用程序添加入站出站规则),我无法弄清楚如何解决这个问题。任何人都可以帮我解决这个问题。非常感谢。
解决方案
推荐阅读
- python - 实现 Karatsuba 算法时的整数除法
- time-series - 不规则时间序列预测
- linux - 如何在 Ubuntu 中检查 .tar(不是 tar.gz)文件是否损坏?
- html - 使用 CSS 和 html 根据 id 更改颜色
- python - 使用 Keras 中的 LSTM 在时间 t+m 进行多元时间序列预测
- python - 多对多关系中的唯一约束
- python - 如何从数据框中获取列表中的前 5 名
- java - 坐标不会消失
- javascript - 三星互联网视口问题上的 A-Frame + AR.js
- nginx - 是否可以使用正则表达式将 nginx 错误日志解析为与 cloudwatch 洞察一起使用的网络