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 根本不是我要访问的. 报错 ...
随机推荐
- Python自学
print("\u4e2d\u56fd\") 报错,语法错误 修改,去掉尾部的\,正确 import datetimeprint("now:"+datetime ...
- Java Calendar使用
import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.Calendar; impor ...
- vue城市选择组件
适用于vue的城市选择组件 仓库地址 基本功能: 支持全选.反选以及全部清空. 支持按拼音筛选. 勾选省份将会勾选省份下所有城市. 返回数据可灵活处理. 安装 npm install cn-regio ...
- Homebrew学习(一)之初认识
Homebrew Homebrew是一款Mac OS平台下的软件包管理工具,拥有安装.卸载.更新.查看.搜索等很多实用的功能.简单的一条指令,就可以实现包管理,而不用你关心各种依赖和文件路径的情况,会 ...
- C++中如何实现split的效果?
C++中如何实现split的效果? 和Python等语言不同,C++的string类没有内置split函数,这对于实际应用中要经常分割字符串的情况非常不方便.有很多种方法来处理,这里讲一种比较方(to ...
- CTP报单参数详解
交易所代码 产品类型 业务类型 价格类型 指令类型 价格类型 OrderPriceType 有效期类型 TimeCondition 成交量类型 VolumeCondition 备注 CZCE 郑商所 ...
- 深入理解java虚拟机(3)垃圾收集器与内存分配策略
一.根搜索算法: (1)定义:通过一系列名为"GC Roots"的对象作为起点,从这些起点开始向下搜索,搜索走过的路径称为引用链,当一个对象到GC Roots没有任何引用链相连的时 ...
- PHP实现无限极分类的两种方式
无限极分类说简单点就是一个类可以分成一个分子类,然后一个子类又可以分另一个子类这样无限分下去,就是好象windows可以新建一个文件夹,然后在这个文件夹里又可以建一个文件夹,PHP要实现无限极分类有两 ...
- git ssh 绑定 GitLab
入职新公司之后,需要使用GitLab,可是我不会啊,又不想麻烦运维大佬,所以自己找乐一下,发现网上都是些很陈旧的教程,所以准备自己记录下来 第一步 设置Git端上的用户名和用户邮箱: 假如入你已经安装 ...
- python virtualenv和virtualenv的使用
首先下面的步骤我都是在windows下执行,Python2.7,pip==19.1.1 1.安装virtualenv pip install virtualenv 2.新建virtualenv vir ...