spring - Kubernetes中的Spring Rest模板奇怪行为
问题描述
我在 Kubernetes(谷歌云)中有两个 Spring Boot 服务。
Service1 使用 org.springframework.web.client.RestTemplate 对使用 Service 名称的 Service2 执行 http 请求。在这两种情况下,Service1 都会收到以下错误:org.springframework.web.util.NestedServletException:请求处理失败;嵌套异常是 org.springframework.web.client.ResourceAccessException: I/O error on POST request for " http://service1/tcp:/10.11.252.122:8080 ": Connection denied (Connection denied); 嵌套异常是 java.net.ConnectException: Connection denied (Connection denied)
当 10.11.252.122 为 Service2 集群 IP 时。
仅当 Service1 和 Service2 在同一个集群中时才会发生,在其他情况下代码可以正常工作。
什么会导致 Spring 将 tcp:/Cluser IP 添加到 url?
谢谢,
解决方案
推荐阅读
- python - dict 的类型提示给出 TypeError: 'type' object is not subscriptable
- react-native - createBottomTabNavigator 如何修改标题?
- angular - Angular Material Select Dropdown,发出整个对象项,而不仅仅是一个值
- talend - tExtractJSON 表为空 Talend
- ansible - 在变量等号中使用时出现 Ansible 错误
- c++ - 有没有办法在程序结束之前获取退出代码?
- javascript - 修复 bootstrap daterangepicker 在 bootstrap 3.3.7 上无法正确显示
- matlab - 在 Matlab 中求解微分方程 - 体外溶出度
- javascript - 有没有一种方法/API 可以保存网页资产,它适用于 HTTP,而不仅仅是 HTTPS?
- flutter - 带有模板的 Flutter 包提供程序