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 根本不是我要访问的. 报错 ...
随机推荐
- centos7下安装phpmyadmin
安装环境 在同一台主机上部署LAMP Linux( CentOS 7.3 ) .Apache(httpd2.4).MariaDB(5.5).PHP(7.2) 主机IP:192.168.137.200 ...
- 01: jenkins简介与安装
jenkins参考博文:https://www.w3cschool.cn/jenkins/jenkins-173a28n4.html Jenkins中文官网:http://www.jenkins.or ...
- python 链接mysql
下载对应版本 安装 https://dev.mysql.com/downloads/connector/python/ 创建链接 # python 链接mysqlimport mysql.conn ...
- 如何把maven文件pom.xml中的java包下载下来
右击pom.xml文件,选择Run As-->Maven build- 在打开的页面中,如图输入"dependency:copy-dependencies",后点击" ...
- 初探CSS -3 语法
CSS 语法 实例 <!DOCTYPE html> <html> <head> <meta charset="utf-8"> < ...
- MySQL的简单条件判断语句
在MySQL中条件判断语句常用于数据转换,基于现有数据创建新的数据列,使用场景还是比较多. 基础样式: CASE WHEN`条件`THEN`结果` ELSE`默认结果` END 在同一条判断语句中可以 ...
- 了解ffmpeg生态
我以前整理的ffmpeg相关资料: 了解ffmpeg要读的资料 https://blog.csdn.net/yyhustim/article/details/9078941 ffmpeg和ffserv ...
- BFPRT: O(n)最坏时间复杂度找第K大问题
同时找到最大值与最小值 找到n个元素中的最大/小值,比较次数为n-1, 找到n个元素中的最大值和最小值,可以Two Pass,比较次数为2n-2 也可以One Pass,比较次数至多为\(\left ...
- 清北学堂提高组突破营游记day4
今天主攻图论. 对于这道题,30分做法是暴力搜索全部来判断是否有异样. 对于满分做法,利用带权并查集.? 又带我们串了一边LCA 安利个人LCA博客. spfa代码.原理:循环队列. 然后是floyd ...
- Sublime Text2 常用快捷键总结
Ctrl+Tab 当前窗口中的标签页切换 Ctrl+Shift+D 复制光标所在整行,插入在该行之前 Ctrl+Shift+K 删除整行 Ctrl+Shift+/ 注释已选择内容 Ctrl+Shift ...