1

My code below is in .netcore 3.1 (use RabbitMQ.Client 6.1) to connect to 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();

I publish the code using self-container and it works well in a machine (Windows 10), however when I run it in a Windows 7, I got this error.

[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()

After a while digging the error and search and try (for example turn off firewall, add rules for inbound outbound for my application), I could not figure out how to fix this. Anyone could help me to fix this. Thank you very much.

Projector
  • 11
  • 2
  • If it's on Amazon, then might you have forgotten to configure a firewall at the Amazon end? – Caius Jard Dec 24 '20 at 20:11
  • All clients are my local machines, not on Amazon. I actually run the code well in several machines with Windows 10 (can create connection, get messages in Queue), but fail in Windows 7. – Projector Dec 24 '20 at 20:24
  • I the Win7 the client or the server – Caius Jard Dec 24 '20 at 21:38
  • Server is Amazon MQ (RabbitMQ), Win7 is our client @CaiusJard – Projector Dec 24 '20 at 21:49
  • OK, so first things first; can you telnet to the RMQ server on port 5672, from the win7 client? – Caius Jard Dec 24 '20 at 21:52
  • Yes, I can telnet to RMQ, but the port is 5671, not 5672 – Projector Dec 24 '20 at 21:58
  • OK, so you know the connection works.. are you certain the credentials are correct (next in the error message is authentication falure) – Caius Jard Dec 24 '20 at 22:00
  • I think it is correct, because when I run it on a Windows 10, it worked well. Can connect, get messages from the queue. But error when run on Windows 7, code is the same package and config. – Projector Dec 24 '20 at 22:03
  • It's most likely that AWS wants TLS 1.2 and your Windows 7 (which you really shouldn't be using anymore) doesn't support it. – CodeCaster Dec 25 '20 at 08:54
  • But I used the same code, same deployment. The one running on Win10 also doesn't use TLS to connect to AWS but still works well. Do you think there's any other reason? – Projector Dec 25 '20 at 09:26
  • Windows 10 definitely uses TLS to connect to AWS. The point is that you use a library, which internally uses a .NET API that calls into a Windows API to make the HTTP request to AWS. Different versions and updates of Windows have different capabilities for making HTTP requests. – CodeCaster Dec 25 '20 at 13:02
  • Just search "Windows 7 enable TLS 1.2" or something like that, it's probably just that. – CodeCaster Dec 25 '20 at 13:02
  • 1
    It might be true @CodeCaster, and thank you for the hint. I will try to do it later and will update the result right after I get it. Merry Christmas. – Projector Dec 25 '20 at 18:20
  • Hi @CodeCaster, after I enable TLS 1.2 on Win7 and update hotfix kb3140245, I got another error as follows, it seems that still relates to SSL issue – Projector Dec 28 '20 at 07:43
  • Error is: Error is: System.Net.Sockets.SocketException (10054): An existing connection was forcibly closed by the remote host. at System.Net.FixedSizeReader.ReadPacketAsync(Stream transport, AsyncProtocolRequest request) – Projector Dec 28 '20 at 07:47

0 Answers0