Binding external IP address to Rabbit MQ server

2019-03-27 13:15发布

问题:

I have box A and it has a consumer on it that listens on a Rabbit MQ server

I have box B that will publish a message to the listener

So as long as all of this in on box A and I start Rabbit MQ server w/ defaults it works fine.

The defaults are host=127.0.0.1 on port 5672, but when I telnet box.a.ip.addy 5672 from box B I get:

Trying  box.a.ip.addy...
telnet: connect to address  box.a.ip.addy: No route to host
telnet: Unable to connect to remote host: No route to host

telnet on port 22 is fine, I can ssh into Box A from Box B

So I assume I need to change the ip that the RabbitMQ server uses I found this: http://www.rabbitmq.com/configure.html and I now have a config file in the location the documentation said to use, with the name rabbitmq.config and it contains:

[
    {rabbit, [{tcp_listeners, {"box.a.ip.addy", 5672}}]}
].

So I stopped the server, and started RabbitMQ server again. It failed. Here are the errors from the error logs. It's a little over my head. (in fact most of this is)

=ERROR REPORT==== 23-Aug-2011::14:49:36 ===
FAILED
Reason: {{case_clause,{{"box.a.ip.addy",5672}}},
         [{rabbit_networking,'-boot_tcp/0-lc$^0/1-0-',1},
          {rabbit_networking,boot_tcp,0},
          {rabbit_networking,boot,0},
          {rabbit,'-run_boot_step/1-lc$^1/1-1-',1},
          {rabbit,run_boot_step,1},
          {rabbit,'-start/2-lc$^0/1-0-',1},
          {rabbit,start,2},
          {application_master,start_it_old,4}]}

=INFO REPORT==== 23-Aug-2011::14:49:37 ===
    application: rabbit
    exited: {bad_return,{{rabbit,start,[normal,[]]},
                         {'EXIT',{rabbit,failure_during_boot}}}}
    type: permanent

and here is some more from the start up log:

Erlang has closed
Error: {node_start_failed,normal}
^M
Crash dump was written to: erl_crash.dump^M
Kernel pid terminated (application_controller) ({application_start_failure,rabbit,{bad_return,{{rabbit,start,[normal,[]]},{'EXIT',{rabbit,failure_during_boot}}}}})^M

Please help

回答1:

did you try adding?

RABBITMQ_NODE_IP_ADDRESS=box.a.ip.addy

to the /etc/rabbitmq/rabbitmq.conf file?

Per http://www.rabbitmq.com/configure.html#customise-general-unix-environment

Also per this documentation it states that the default is to bind to all interfaces. Perhaps there is a configuration setting or environment variable already set in your system to restrict the server to localhost overriding anything else you do.

UPDATE: After reading again I realize that the telnet should have returned "Connection Refused" not "No route to host." I would also check to see if you are having a firewall related issue.



回答2:

You need to open up the tcp port on your firewall

Using Linux, Find the iptables config file:

eric@dev ~$ find / -name "iptables" 2>/dev/null
/etc/sysconfig/iptables

Edit the file:

sudo vi /etc/sysconfig/iptables

Fix the file by adding a port:

# Generated by iptables-save v1.4.7 on Thu Jan 16 16:43:13 2014
*filter
-A INPUT -p tcp -m tcp --dport 15672 -j ACCEPT
COMMIT


标签: ip rabbitmq