[英]AWS ECS - Can't connect to RabbitMQ EC2 instance from ECS container instance on the same subnet
I am building an application where I will have multiple Docker services
running on ECS container instance
communicating with each other via RabbitMQ
which runs on a separate EC2 instance
in the same VPC
and in the same subnet.我正在构建一个应用程序,我将在
ECS container instance
上运行多个Docker services
通过RabbitMQ
相互通信, RabbitMQ
在同一VPC
和同一子网中的单独EC2 instance
上运行。 The RabbitMQ
security group is configured to allow all the traffic from that subnet. RabbitMQ
安全组配置为允许来自该子网的所有流量。
However, when I start the service
and it tries to connect to RabbitMQ
I get an error saying ECONNREFUSED 127.0.0.1:5672
.但是,当我启动该
service
并尝试连接到RabbitMQ
我收到一条错误消息,指出ECONNREFUSED 127.0.0.1:5672
。 This is the url that I am using t connect amqp://username:password@ipaddr:5672/?heartbeat=60
.这是我使用的 url 连接
amqp://username:password@ipaddr:5672/?heartbeat=60
。 The network mode for Docker
is default/Bridge
. Docker
的网络模式是default/Bridge
。
I am setting the connection url via an environment variable and I did ssh
into the ECS
container instance and then docker exec -it cntainerID /bin/bash
and was able to verify that the environment variable is set.我正在通过环境变量设置连接 url,我将
ssh
到ECS
容器实例,然后docker exec -it cntainerID /bin/bash
并能够验证环境变量是否已设置。
127.0.0.1
is not the IP address of the EC2 RabbitMQ server. 127.0.0.1
不是 EC2 RabbitMQ 服务器的 IP 地址。 That address will always point to what ever machine the code is running on, it is called "localhost".该地址将始终指向运行代码的机器,称为“localhost”。
You need to be using the private IP of the EC2 server running RabbitMQ.您需要使用运行 RabbitMQ 的 EC2 服务器的私有 IP 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.