5

I installed fresh RabbitMQ 3.1.3 on ubuntu 12.04.2 LTS by apt-get, and try to start consumers on the same server, but I have connection problem:

[PhpAmqpLib\Exception\AMQPRuntimeException]         
Error Connecting to server(113): No route to host

There is status of working server:

Status of node rabbit@ns1 ...
[{pid,2106},
 {running_applications,[{rabbit,"RabbitMQ","3.1.3"},
                        {mnesia,"MNESIA  CXC 138 12","4.5"},
                        {os_mon,"CPO  CXC 138 46","2.2.7"},
                        {xmerl,"XML parser","1.2.10"},
                        {sasl,"SASL  CXC 138 11","2.1.10"},
                        {stdlib,"ERTS  CXC 138 10","1.17.5"},
                        {kernel,"ERTS  CXC 138 10","2.14.5"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang R14B04 (erts-5.8.5) [source] [64-bit] [smp:4:4] [rq:4] [async-threads:30] [kernel-poll:true]\n"},
 {memory,[{total,27728944},
          {connection_procs,2704},
          {queue_procs,5408},
          {plugins,0},
          {other_proc,9021680},
          {mnesia,60016},
          {mgmt_db,0},
          {msg_index,31144},
          {other_ets,770736},
          {binary,1968},
          {code,14560395},
          {atom,1356081},
          {other_system,1918812}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1262847590},
 {disk_free_limit,1000000000},
 {disk_free,214706556928},
 {file_descriptors,[{total_limit,924},
                    {total_used,3},
                    {sockets_limit,829},
                    {sockets_used,1}]},
 {processes,[{limit,1048576},{used,125}]},
 {run_queue,0},
 {uptime,1265}]
...done.

I don't have any limitations by iptables (ports):

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

And etc/hosts is OK.

127.0.0.1 localhost
{IP-ADDRESS} ns1.***.org  ns1
# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Whay I'm doing wrong?

UPD: sudo netstat -nlp | grep 5672 returns: tcp6 0 0 :::5672 :::* LISTEN 2106/beam.smp

From rabbitMQ logs:

=INFO REPORT==== 2-Jul-2013::16:05:11 ===
started TCP Listener on [::]:5672

=INFO REPORT==== 2-Jul-2013::16:05:11 ===
Server startup complete; 0 plugins started.

=INFO REPORT==== 2-Jul-2013::16:35:04 ===
accepting AMQP connection <0.1130.0> (127.0.0.1:44112 -> 127.0.0.1:5672)

=ERROR REPORT==== 2-Jul-2013::16:35:14 ===
closing AMQP connection <0.1130.0> (127.0.0.1:44112 -> 127.0.0.1:5672):
{handshake_timeout,handshake}

I tried to change localhost to ip6-localhost and sometimes when try to starting consumer, it returns:

[PhpAmqpLib\Exception\AMQPRuntimeException]             
Error Connecting to server(110): Connection timed out

UPD2 If I start consumer with debug flag and --env=prod (php .../app/console rabbitmq:consumer -w -d consumer_name), consumer starts and working.

Quantizer
  • 113
  • 1
  • 1
  • 7
  • please, attach script source code you are trying to connect with – pinepain Jul 02 '13 at 13:47
  • I'll try to start consumer from Symfony2 console by [RabbitMQBundle](https://github.com/videlalvaro/rabbitmqbundle) with parameters of connection localhost:5672, vhost: / – Quantizer Jul 02 '13 at 14:02
  • Can you connect to web admin interface (if enabled) on port 15672 by default? Did you explicitly pass connection arguments or use default one? – pinepain Jul 02 '13 at 14:26
  • I'll try to wget from console on server, and get ~$ wget localhost:15672 --2013-07-02 16:30:26-- http://localhost:15672/ Resolving localhost (localhost)... 127.0.0.1 Connecting to localhost (localhost)|127.0.0.1|:15672... failed: Connection refused. – Quantizer Jul 02 '13 at 14:31
  • I use default connection arguments. – Quantizer Jul 02 '13 at 14:37
  • can you provide config and probably turn on webadmin panel just add this to your config: {rabbitmq_management, [{listener, [{port, 15672}]}]} – pinepain Jul 02 '13 at 16:01
  • I turn on with sudo `rabbitmq-plugins enable rabbitmq_management`, but telnet localhost 15672 Trying 127.0.0.1... telnet: Unable to connect to remote host: Connection refused – Quantizer Jul 02 '13 at 16:38
  • hmmm, drop me a message in skype (same login), it's an interesting problem, stack-overflow doesn't like long discussions in comments – pinepain Jul 02 '13 at 17:19
  • See more in depth answer to duplicate question here: http://stackoverflow.com/questions/21828937/php-client-cant-connect-to-rabbitmq-server-on-localhost/27740555#27740555 – geoidesic Jan 02 '15 at 10:22

2 Answers2

3

If the necessary ports are not open on the rabbitmq server, you get this "No route to host" error when the client tries to connect.

To fix it, make sure the ports are open, if not, open them:

sudo iptables -I INPUT -p tcp --dport 5672 --syn -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 5673 --syn -j ACCEPT
sudo iptables -I INPUT -p tcp --dport 15672 --syn -j ACCEPT

This sets it on temporally. Set it permanently with your iptables.

sudo vi /etc/sysconfig/iptables

Then restart:

sudo service iptables restart
Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
2

Problem was fixed with reconfiguring listen address from 0.0.0.0:5672 to 127.0.0.1:5672 and small security fixes in OS.

Eric Leschinski
  • 146,994
  • 96
  • 417
  • 335
Quantizer
  • 113
  • 1
  • 1
  • 7
  • See more in depth answer to this question here... http://stackoverflow.com/questions/21828937/php-client-cant-connect-to-rabbitmq-server-on-localhost/27740555#27740555 – geoidesic Jan 02 '15 at 10:22