我有两个 Spring Boot 应用程序,都使用 Spring Cloud Zookeeper 进行服务发现,其中一个使用 Feign 与另一个对话,如此处所述
当部署在 localhost 和作为 docker 映像时,一切正常,docker-compose
但是当作为单独的任务/服务部署到 AWS ECS(使用默认网络模式awsvpc
)时,两者之间的通信不再有效,并且 Feign 客户端错误如下:
feign.FeignException$NotFound: [404 ] during [GET] to [http://my-api/api/workspace-context] [APIKeyService#getContextFromAPIKey(String)]: [<!doctype html><html lang="en"><head><title>HTTP Status 404 – Not Found</title><style type="text/css">body {font-family:Tahoma,Arial,sans-serif;} h1, h2, h3, b {color:white;background-color:#525D76;} ... (431 bytes)]
请注意,这里的响应有点像标准的 Tomcat 404 响应。
我已经看到了此 AWS 部署存储在 Zookeeper 中的值,它似乎将 IP 地址作为 的值address
,我不确定这是否正确。
{
"name": "my-api",
"id": "323be0b7-8ad8-4061-846e-abcdac2bbbca",
"address": "169.254.xxx.xxx",
"port": 8080,
"sslPort": null,
...
此 IP 地址与 ECS 任务关联的 ENI 的公网 IP 和私有 IP 均不匹配。
如果我用 ENI 的公共 IP 手动替换该address
Zookeeper 条目的值,它会再次开始正常工作(但不能使用私有 IP)。但显然,在新部署后它会再次被破坏。
任何帮助表示赞赏