客户端无法连接到远程Rabbitmq服务器

时间:2015-07-17 18:43:09

标签: rabbitmq celery google-compute-engine

我在机器A上运行Rabbitmq服务器,可以将任务放入消息队列。机器B应该连接到机器A上的AMQP服务器并执行任务。我的rabbitmq-env.conf设置为:

NODE_IP_ADDRESS=
NODE_PORT=5672

我可以在本地连接到机器A上的服务器。运行时nmap -p 5672 localhost。它显示:

Nmap scan report for localhost (127.0.0.1)
Host is up (0.000094s latency).
PORT     STATE SERVICE
5672/tcp open  amqp

但是在机器B上,当运行Celery工作者时,它说:

consumer: Cannot connect to amqp://myuser:**@{server_IP}:5672/myvhost: timed out.

nmap -p 5672 {server_IP}显示:

Host is up (0.0013s latency).
PORT     STATE    SERVICE
5672/tcp filtered amqp

我可以肯定我在Celery中的Broker url设置是正确的,而且我没有使用rabbitmq的访客帐户。

我的服务器状态显示:

[{pid,2580},
 {running_applications,[{rabbit,"RabbitMQ","3.2.4"},
                        {os_mon,"CPO  CXC 138 46","2.2.14"},
                        {xmerl,"XML parser","1.3.5"},
                        {mnesia,"MNESIA  CXC 138 12","4.11"},
                        {sasl,"SASL  CXC 138 11","2.3.4"},
                        {stdlib,"ERTS  CXC 138 10","1.19.4"},
                        {kernel,"ERTS  CXC 138 10","2.16.4"}]},
 {os,{unix,linux}},
 {erlang_version,"Erlang R16B03 (erts-5.10.4) [source] [64-bit] [async-threads:30] [kernel-poll:true]\n"},
 {memory,[{total,40419400},
          {connection_procs,205272},
          {queue_procs,60240},
          {plugins,0},
          {other_proc,13473800},
          {mnesia,75128},
          {mgmt_db,0},
          {msg_index,30440},
          {other_ets,748888},
          {binary,5264592},
          {code,16522377},
          {atom,594537},
          {other_system,3444126}]},
 {vm_memory_high_watermark,0.4},
 {vm_memory_limit,1552420044},
 {disk_free_limit,50000000},
 {disk_free,6313250816},
 {file_descriptors,[{total_limit,924},
                    {total_used,7},
                    {sockets_limit,829},
                    {sockets_used,3}]},
 {processes,[{limit,1048576},{used,153}]},
 {run_queue,0},
 {uptime,8}]
...done.

机器A和机器B都是同一项目下的Google Compute Engine VM。任何输入将不胜感激。非常感谢。

1 个答案:

答案 0 :(得分:1)

事实证明这是一个安全问题。 Rabbitmq默认侦听所有Internet接口,并且只要所使用的帐户不是guest虚拟机,就允许远程连接。对于GCE实例之间的连接,应使用内部IP地址或仅使用实例名称。默认情况下允许内部连接。但谷歌禁止外部的。所以只需将'server_IP'更改为内部IP或实例名称,所有内容都像魔术一样。