Connecting to RabbitMQ via hostname/ip (using NServiceBus)

时间:2016-04-04 18:40:14

标签: rabbitmq connection-string nservicebus

I am using NServiceBus (5.x) with RabbitMQ (3.6) as the transport. This connection string works:

 <connectionStrings>
<add name="NServiceBus/Transport"
     connectionString="host=localhost;username=****;password=***;RequestedHeartbeat=600;"/>
</connectionStrings>

But on the same server (where RabbitMQ server is installed), using host name or IP doesn't work:

 <connectionStrings>
<add name="NServiceBus/Transport"
     connectionString="host=myServerPC;username=****;password=***;RequestedHeartbeat=600;"/>
</connectionStrings>

I get this error:

2016-04-04 14:37:45.370 ERROR NServiceBus.Transports.RabbitMQ.RabbitMqConnectionManager Failed to connect to Broker: 'myServerPC', Port: 5672 VHost: '/'. ExceptionMessage: 'None of the specified endpoints were reachable'

I have tried the following:

  1. Created my own admin user (not guest) and verified it by logging into the RabbitMQ Management UI. Works from remote machine too. All using myServerPC.
  2. Installed license for NServicebus using Service Insight -> Register.

Thank you!

1 个答案:

答案 0 :(得分:0)

最有可能的原因是你的RabbitMq实例只监听localhost。检查RABBITMQ_NODE_IP_ADDRESS的配置,它应该为空或包含您的主机外部IP地址。如果是127.0.0.1localhost,则只能使用您的环回地址连接到RabbitMq。