mattherman
mattherman

Reputation: 466

Unable to connect to Amazon MQ using MassTransit

I am attempting to publish messages to an Amazon MQ instance using the latest version of the MassTransit.ActiveMQ package.

I found an example in the MassTransit source that appears to show a successful connection to Amazon MQ. I tried to replicate that example in my own application using my Amazon MQ instance:

public static void Main(string[] args)
{
    Console.WriteLine("Creating connection to Amazon MQ...");
    var busControl = Bus.Factory.CreateUsingActiveMq(cfg =>
    {
        cfg.Host("b-abcxyz-1.mq.us-east-1.amazonaws.com", 61617, h =>
        {
            h.Username("user");
            h.Password("pass");
            h.UseSsl();
        });
    });

    busControl.StartAsync().Wait();

    Console.WriteLine("Connected.");
    Console.ReadKey();

    busControl.StopAsync().Wait();
}

I receive the following error when attempting to start the bus. It seems to use the activemq scheme instead of ssl like I expected.

ActiveMQ Connect Failed: ReceiveTranport Faulted, Restartingactivemq://b-abcxyz-1.mq.us-east-1.amazonaws.com:61617/

Unhandled Exception: System.AggregateException: One or more errors occurred. (ReceiveTranport Faulted, Restartingactivemq://b-abcxyz-1.mq.us-east-1.amazonaws.com:61617/) ---> MassTransit.ActiveMqTransport.ActiveMqConnectException: ReceiveTranport Faulted, Restartingactivemq://b-72f33f22-0856-47ef-a5fb-e0ab19ab7aff-1.mq.us-east-1.amazonaws.com:61617/ ---> System.NotSupportedException: The requested security protocol is not supported.
   at System.Net.SecurityProtocol.ThrowOnNotAllowed(SslProtocols protocols, Boolean allowNone)
   at System.Net.Security.SslStream.AuthenticateAsClient(String targetHost, X509CertificateCollection clientCertificates, SslProtocols enabledSslProtocols, Boolean checkCertificateRevocation)
   at Apache.NMS.ActiveMQ.Transport.Tcp.SslTransport.CreateSocketStream()
   at Apache.NMS.ActiveMQ.Transport.Tcp.TcpTransport.Start()
   at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
   at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
   at Apache.NMS.ActiveMQ.Transport.WireFormatNegotiator.Start()
   at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
   at Apache.NMS.ActiveMQ.Transport.TransportFilter.Start()
   at Apache.NMS.ActiveMQ.Connection.CheckConnected()
   at Apache.NMS.ActiveMQ.Connection.Start()
   at MassTransit.ActiveMqTransport.Transport.ConnectionContextFactory.<CreateConnection>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MassTransit.ActiveMqTransport.Transport.ConnectionContextFactory.<CreateSharedConnection>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GreenPipes.Agents.PipeContextSupervisor`1.<GreenPipes-IPipeContextSource<TContext>-Send>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at GreenPipes.Agents.PipeContextSupervisor`1.<GreenPipes-IPipeContextSource<TContext>-Send>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at GreenPipes.Agents.PipeContextSupervisor`1.<GreenPipes-IPipeContextSource<TContext>-Send>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MassTransit.ActiveMqTransport.Transport.ActiveMqReceiveTransport.<<Receiver>b__15_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MassTransit.ActiveMqTransport.Transport.ActiveMqReceiveTransport.<<Receiver>b__15_0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MassTransit.Policies.PipeRetryExtensions.<Retry>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MassTransit.Policies.PipeRetryExtensions.<Retry>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MassTransit.ActiveMqTransport.Transport.ActiveMqReceiveTransport.<Receiver>d__15.MoveNext()
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MassTransit.ActiveMqTransport.Transport.ActiveMqHost.Handle.<ReadyOrNot>d__7.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MassTransit.MassTransitBus.Handle.<ReadyOrNot>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at GreenPipes.Internals.Extensions.TaskExtensions.<UntilCompletedOrCanceled>d__0`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at MassTransit.MassTransitBus.<StartAsync>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at MassTransit.MassTransitBus.<StartAsync>d__27.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at MassTransitActiveMQ.Program.Main(String[] args) in /home/ec2-user/MassTransitActiveMQ/MassTransitActiveMQ/Program.cs:line

Upvotes: 0

Views: 1445

Answers (1)

Chris Patterson
Chris Patterson

Reputation: 33298

I've resolved the issue, related to the SSL (requires TLS) protocol and will be committing the fix shortly. It will be available in version 5.0.2 soon.

Upvotes: 2

Related Questions