RestTemplate 调用本地服务 connection refused
当需要使用服务间的互相调用的时候,通常来说最优雅的方式莫过于Feign调用了。但是有时候特殊原因还是需要使用httpClient之类的工具。
本次我在使用RestTemplate调用本地服务的时候,会出现如下错误:
Servlet.service() for servlet [dispatcherServlet] in context with path []
threw exception [Request processing failed; nested exception is org.springframework.web.client.ResourceAccessException:
I/O error on GET request for "https://xx/xx/xx": Connect to xx:xx [xx/xx] failed:
Connection refused (Connection refused); nested exception is org.apache.http.conn.HttpHostConnectException:
Connect to xx:xx [xx/xx] failed: Connection refused (Connection refused)]
with root cause
用同样的代码调用其他服务器上的服务时并未出现这样的错误,曾一度怀疑是url有误,然而浪费了很多时间去尝试这个。然后又怀疑是网关,或防火墙阻拦了?,然而又浪费了很多时间。
刷了会微博冷静了下,才想起来可能是url地址的写法有误。
当调用本地服务的时候,url应该写成
https://localhost:xx/xx/xx (我想应该也可以写成服务名代替ip的那种吧,)
然而,改完之后,还是有问题,不过还好的是错误变了:
org.springframework.web.util.NestedServletException: Request processing failed;
nested exception is org.springframework.web.client.ResourceAccessException: I/O error on GET request for "https://localhost:xx/xx/xx":
Unrecognized SSL message, plaintext connection?; nested exception is javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?
这个错是使用https请求了http服务,很好改:
http://localhost:xx/xx/xx
o了。
RestTemplate 调用本地服务 connection refused的更多相关文章
- 使用 RestTemplate 调用 restful 服务
什么是RestTemplate? RestTemplate是Spring提供的用于访问Rest服务的客户端,RestTemplate提供了多种便捷访问远程Http服务的方法,能够大大提高客户端的编写效 ...
- 使用 Spring RestTemplate 调用 rest 服务时自定义请求头(custom HTTP headers)
在 Spring 3.0 中可以通过 HttpEntity 对象自定义请求头信息,如: private static final String APPLICATION_PDF = "app ...
- 调用远程主机上的 RMI 服务时抛出 java.rmi.ConnectException: Connection refused to host: 127.0.0.1 异常原因及解决方案
最近使用 jmx 遇到一个问题,client/server 同在一台机器上,jmx client能够成功连接 server,如果把 server 移植到另一台机器上192.168.134.128,抛出 ...
- Eureka服务注册中心错误:com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
报错信息 14:43:45.484 [main] INFO com.netflix.discovery.DiscoveryClient - Getting all instance registry ...
- springCloud 服务注册启动报错<com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect>
报错:com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: ...
- Redis 服务端配置——Could not connect to Redis at 127.0.0.1:6379: Connection refused
[root@centoszang 桌面]# redis-cli Could : Connection refused Could : Connection refused not connected& ...
- Eureka服务注册中心相关错误com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused: connect
启动项目报错如下 原因: 在默认设置下,Eureka服务注册中心也会将自己作为客户端来尝试注册它自己,所以会出现 com.sun.jersey.api.client.ClientHandlerExce ...
- 阿里云配置通用服务的坑 ssh: connect to host 47.103.101.102 port 22: Connection refused
1.~ wjw$ ssh root@47.103.101.102 ssh: connect to host 47.103.101.102 port 22: Connection refused ssh ...
- Weblogic 连接 RMI 服务报错 Connection refused
WebLogic 连接 RMI 服务报错 Connection refused 访问 WebLogic RMI 服务报错,连接被拒绝,连接超时. 奇怪的是,报错的 host 根本不是我要访问的. 报错 ...
随机推荐
- [.net core]5.outProcess
与inProcess比较 OutProcess性能更差,因为此时它使用了两个web服务器 ,内部是kestrel 外部可能是iis apache nginx 等. 使用visual studio ...
- HTTP 缓存简单了解
HTTP 缓存简单了解.文章整理了相关资料,记录了部分实践.方便大家轻松了解缓存.能回答上三个问题,HTTP缓存就算理解呢.能否缓存?缓存是否过期?协商缓存? 概要: web缓存 缓存的处理 前端解决 ...
- info - 阅读 info 文档
SYNOPSIS 总览 info [OPTION]... [MENU-ITEM...] DESCRIPTION 描述 阅读 info 格式的文档. OPTIONS 选项 --apropos=STRIN ...
- python之堆排序算法代码
以下是个人写的堆排序代码,原理我就不解释了(简单来说就是先建立一个大顶堆,然后进行顶点和最后节点的互换,互换之后需要重新建堆,两两比对,具体的话可以参照其他的,不过代码还是会于注释的. #根据问题进行 ...
- 牛客假日团队赛5 L Catch That Cow HDU 2717 (BFS)
链接:https://ac.nowcoder.com/acm/contest/984/L 来源:牛客网 Catch That Cow 时间限制:C/C++ 1秒,其他语言2秒 空间限制:C/C++ 3 ...
- shell报错:-bash: [: ==: 期待一元表达式 解决方法 ([: ==: unary operator expected)
shell报错:-bash: [: ==: 期待一元表达式 解决方法 ([: ==: unary operator expected) blogdaren 2015-02-26 抢沙发 14916人 ...
- c++列举出本地打印机和网络打印机名称
主要使用EnumPrinters函数 该函数枚举可用的打印机,打印服务器,域或印刷服务供应商. 代码:(开箱即用) #include <Windows.h> #include <st ...
- 转:ThreadLocal剖析
转自http://www.cnblogs.com/dolphin0520/p/3920407.html 一.对ThreadLocal的理解 ThreadLocal,很多地方叫做线程本地变量,也有些地方 ...
- Flask【第10篇】:自定义Form组件
自定义Form组件 一.wtforms源码流程 1.实例化流程分析 1 # 源码流程 2 1. 执行type的 __call__ 方法,读取字段到静态字段 cls._unbound_fields 中: ...
- ZROI 19.07.29 线性代数入门/wq
1.高斯消元 在模意义下依然有效,对主元求逆即可. 甚至可以模合数,需要对两个方程辗转相除,复杂度\(O(n^3\log p)\). 辗转相除法只要能定义带余除法就有效. 逆矩阵:对于矩阵\(A\), ...