Masstransit: RabbitMq non default port not picked up

Created on 5 Jun 2016  路  4Comments  路  Source: MassTransit/MassTransit

Exception:

MassTransit.RabbitMqTransport.RabbitMqConnectionException: Connect failed: myusername@myservername:3000/myvirtualhost ---> RabbitMQ.Client.Exceptions.BrokerUnreachableException: None of the specified endpoints were reachable ---> RabbitMQ.Client.Exceptions.ConnectFailureException: Connection failed ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:5672

My code:

builder.Register(c =>
  Bus.Factory.CreateUsingRabbitMq(sbc => {
    sbc.UseSerilog();
    sbc.Host(
      new Uri(ConfigurationManager.AppSettings["MyRabbitMQHost"]),
      h => {
        h.Username(ConfigurationManager.AppSettings["MyRabbitMQUsername"]);
        h.Password(ConfigurationManager.AppSettings["MyRabbitMQPassword"]);
      }
    );
  })
)

with the following app settings:

<add key="MyRabbitMQHost" value="rabbitmq://myservername:3000/myvirtualhost" />
<add key="MyRabbitMQUsername" value="myusername" />
<add key="MyRabbitMQPassword" value="mysecret" />

So the 3000 port specification is not picked up and the default port is used: 5672.This port is blocked in the firewall, hence the exception.

Am I specifying the port in a non supported way?

In LinqPad:

var testUri = new Uri("rabbitmq://myserver:3000/test");
testUri.IsDefaultPort.Dump();

it's showing False for the IsDefaultPort so when consulting the MassTransit code ( RabbitMqEndpointAddress.cs) it should pick up the non default port.

Right?

Most helpful comment

Yeah, until 3.6.3 comes out this is broken. You can revert to an older version or just wait for Pivotal to release an updated client.

All 4 comments

So in my tests, this works. So I'm not sure what's happening for you to not get the port picked up.

I believe it is related to ConnectionFactory issue:
https://github.com/rabbitmq/rabbitmq-dotnet-client/issues/186

Hi

I have this error too.
It is related to "RabbitMQ.Client" version="3.6.2". In 3.6.1 all works OK.

Yeah, until 3.6.3 comes out this is broken. You can revert to an older version or just wait for Pivotal to release an updated client.

Was this page helpful?
0 / 5 - 0 ratings