rebus-org / Rebus.RabbitMq

:bus: RabbitMQ transport for Rebus
https://mookid.dk/category/rebus
Other
62 stars 44 forks source link

Issue when connect AmazonMQ for RabbitMQ #80

Closed volethanh closed 2 years ago

volethanh commented 3 years ago

Hi,

I'm using Rebus.RabbitMq and connect to AmazonMQ for RabbitMQ service. The connection is amqps and the Exception was throw in the GetConnection method. When I changed and don't use _amqpTcpEndpoints, It works.

Screen Shot 2021-05-31 at 9 54 32 AM

How can I solve this problem ? Thanks

mookid8000 commented 3 years ago

Could you maybe post the exception here, including the full stack trace?

volethanh commented 3 years ago

This is my full stack trace and exception

Screen Shot 2021-06-04 at 8 39 04 AM
volethanh commented 3 years ago

Hi @mookid8000 , Is there anything you find out ?

mookid8000 commented 3 years ago

No sorry, I haven't figure anything out.

Could you make it work somehow? What did you change to do that?

volethanh commented 3 years ago

No sorry, I haven't figure anything out.

Did you try using the connection from AmazonMQ for RabbitMQ ?

Could you make it work somehow? What did you change to do that?

As you see in the first picture, I've changed the the param pass to the method CreateConnection from CreateConnection(IList<AmqpTcpEndpoint> endpoints) to CreateConnection(string clientProvidedName)

mookid8000 commented 3 years ago

Did you try using the connection from AmazonMQ for RabbitMQ ?

No.

As you see in the first picture, I've changed the the param pass to the method CreateConnection from CreateConnection(IList endpoints) to CreateConnection(string clientProvidedName)

Ok, great. How do you suggest this is solved?

sherzberg commented 3 years ago

I'm also having an issue connecting to AmazonMQ, but I'm not 100% sure I'm using a proper ConnectionEndpoint for SSL. Does this look reasonable in terms of how one would connect to an SSL based rabbitmq?

var ConnectionString = "amqps://username:password@some-guid.mq.us-east-1.amazonaws.com:5671";

var serverConnectionEndpoints = new List<ConnectionEndpoint>
{
    new()
    {
        ConnectionString = ConnectionString,
        SslSettings = new SslSettings(true, "*.mq.us-east-1.amazonaws.com")
    }
};

using var publisher = new BuiltinHandlerActivator();

var publisherBus = Configure.With(publisher)
    .Logging(l => l.ColoredConsole(MinimumLogLevel))
    .Transport(t =>
    {
        t.UseRabbitMqAsOneWayClient(serverConnectionEndpoints);
    })
    .Start();

I have been able to successfully connect to the same AmazonMQ instance by just using a the plain old C# RabbitMQ client.

I'm guessing that the OP's issue was that they weren't supplying SslSettings, as I was getting the same network timeout exception before switching my code to use List<ConnectionEndpoint> when setting up the rebus rabbitmq client.

sherzberg commented 2 years ago

I think I figured out a way around this (or at least my) issue:

var sslSettings = new SslSettings(true, "*.mq.us-east-1.amazonaws.com")
{
    Version = SslProtocols.Tls12
};

It looks like the defaults for CertPassphrase is set to "" and Version is defaulted to TLS when constructing the SslOptions instance in Rebus. The instance in my vanilla RabbitMQ.Client was null for CertPassphrase and None for Version.

I missed these overrides when debugging before I posted my original comment, but I think I'm all up and running now.

mookid8000 commented 2 years ago

Ah great, I'm happy to hear that 🙂

volethanh commented 2 years ago

I think I figured out a way around this (or at least my) issue:

var sslSettings = new SslSettings(true, "*.mq.us-east-1.amazonaws.com")
{
    Version = SslProtocols.Tls12
};

It looks like the defaults for CertPassphrase is set to "" and Version is defaulted to TLS when constructing the SslOptions instance in Rebus. The instance in my vanilla RabbitMQ.Client was null for CertPassphrase and None for Version.

I missed these overrides when debugging before I posted my original comment, but I think I'm all up and running now.

Thanks @sherzberg , I've tried and it run successfully