Php 客户可以';无法连接到本地主机上的RabbitMQ服务器
我通过apt get在Ubuntu12.04.2 LTS上安装了fresh RabbitMQ 3.1.3,并尝试在同一台服务器上启动使用者,但我遇到了连接问题:Php 客户可以';无法连接到本地主机上的RabbitMQ服务器,php,symfony,ubuntu,rabbitmq,ubuntu-12.04,Php,Symfony,Ubuntu,Rabbitmq,Ubuntu 12.04,我通过apt get在Ubuntu12.04.2 LTS上安装了fresh RabbitMQ 3.1.3,并尝试在同一台服务器上启动使用者,但我遇到了连接问题: [PhpAmqpLib\Exception\AMQPRuntimeException] Error Connecting to server(113): No route to host 存在工作服务器的状态: Status of node rabbit@ns1 ... [{pid,2106}, {running_
[PhpAmqpLib\Exception\AMQPRuntimeException]
Error Connecting to server(113): No route to host
存在工作服务器的状态:
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.
我对iptables(端口)没有任何限制:
并且etc/hosts
正常
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
我做错了什么
UPD:
sudo netstat-nlp | grep 5672
返回:tcp6 0:::5672::*LISTEN 2106/beam.smp
从rabbitMQ日志:
=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}
UPD2如果我使用调试标志和
--env=prod
(php…/app/console rabbitmq:consumer-w-d consumer\u name
)启动consumer,使用者启动并工作。将侦听地址从0.0.0.0:5672重新配置为127.0.0.1:5672,并在操作系统中进行了一些小的安全修复,修复了此问题。如果rabbitmq服务器上没有打开必要的端口,则在客户端尝试连接时会出现此“无主机路由”错误
要修复此问题,请确保端口已打开,如果未打开,请打开它们:
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
这是暂时的。使用iptables永久设置它
sudo vi /etc/sysconfig/iptables
然后重新启动:
sudo service iptables restart
请附上您尝试连接的脚本源代码。我将尝试使用参数connection localhost:5672,vhost:/从Symfony2控制台启动使用者。默认情况下,您可以连接到15672端口上的web管理界面(如果启用)?您是否显式地传递了连接参数或使用了默认参数?我将尝试从服务器上的控制台调用wget,并获取~$wget localhost:15672--2013-07-02 16:30:26--解析localhost(localhost)。。。127.0.0.1连接到本地主机(localhost)| 127.0.0.1 |:15672。。。失败:连接被拒绝。我使用默认连接参数。请在此处查看此问题的详细答案。。。
sudo vi /etc/sysconfig/iptables
sudo service iptables restart