2 mythslove mythslove 于 2016.04.14 18:30 提问

CloseableHttpClient报错SSLHandshakeException 3C

CloseableHttpClient使用一段时间后报错无法继续运行
org.apache.http.conn.ConnectTimeoutException: Connect to *:443 [/222.211.64.93] failed: connect timed out
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:143)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)
Caused by: java.net.SocketTimeoutException: connect timed out
at java.net.DualStackPlainSocketImpl.waitForConnect(Native Method)
at java.net.DualStackPlainSocketImpl.socketConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)
at java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)
at java.net.AbstractPlainSocketImpl.connect(Unknown Source)
at java.net.PlainSocketImpl.connect(Unknown Source)
at java.net.SocksSocketImpl.connect(Unknown Source)
at java.net.Socket.connect(Unknown Source)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:337)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
... 12 more
javax.net.ssl.SSLHandshakeException: server certificate change is restricted during renegotiation
at sun.security.ssl.Alerts.getSSLException(Unknown Source)
at sun.security.ssl.SSLSocketImpl.fatal(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.Handshaker.fatalSE(Unknown Source)
at sun.security.ssl.ClientHandshaker.serverCertificate(Unknown Source)
at sun.security.ssl.ClientHandshaker.processMessage(Unknown Source)
at sun.security.ssl.Handshaker.processLoop(Unknown Source)
at sun.security.ssl.Handshaker.process_record(Unknown Source)
at sun.security.ssl.SSLSocketImpl.readRecord(Unknown Source)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at sun.security.ssl.SSLSocketImpl.startHandshake(Unknown Source)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:134)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220)

1个回答

u012850795
u012850795   2016.04.15 15:12

很明显,出现这种问题的原因是读取文件超时,解决方法是将HTTP Keep-Alive Timeout这个参数设置地尽量大,但是有没有更好的解决方法,由于使用的服务器是tomcat,便可以通过修改服务器配置来解决该问题,具体的解决方法如下:
修改tomcat配置文件server.xml,找到类似于下面配置:
1
2
3
4
maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
enableLookups="false" redirectPort="8443" acceptCount="100"
connectionTimeout="20000" disableUploadTimeout="true" />
将上面的参数disableUploadTimeout值改为false即可。

mythslove
mythslove 试过了 解决不了问题 我用的是CloseableHttpClient多次使用就会报错 真不知道PoolingHttpClientConnectionManager的优势在哪儿
2 年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!
其他相关推荐
用httpclient发送https协议请求以及javax.net.ssl.SSLHandshakeException解决办法
本人在做接口自动化的过程中,遇到了请求第三方https协议请求,在经过了短暂的知识重新学习之后,写完代码执行起来总是遇到一个异常,在用客户端执行请求的时候抛出来的,下面是异常的信息: Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
httpclient向HTTPS发送数据建立SSL连接时的错误
httpclient向HTTPS发送数据建立SSL连接时的异常 异常信息如下: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilder
使用HttpUrlConnection或者HttpClient做https请求时导致的SSLHandshakeException异常
最近发现在做https请求时,会报出SSL握手异常 javax.net.ssl.SSLHandshakeException: com.android.org.bouncycastle.jce.exception.ExtCertPathValidatorException: Could not validate certificate signature. 仔细看了下,用HttpUrlConne
使用Apache中的HttpClient的实例CloseableHttpClient的一个例子
Apache的HttpClient可以被用于从客户端发送HTTP请求到服务器端,下面给出一个用HttpClient执行GET和POST请求的操作方法使用maven构建依赖包: <!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient --> <dependen
微信自定义菜单开发报错
微信在自定义菜单生产时,报了下面的错误,原来其中的post地址要把https改成http才行。真蛋碎,如下面 http://api.weixin.qq.com/cgi-bin/menu/create?access_token= javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: PK
CloseableHttpClient NoSuchFieldError错误
CloseableHttpClient client = HttpClients.createDefault();   在andorid里怎么运行的时候报java.lang.NoSuchFieldError:错误,但是main方法就不报错,什么原因呢
com.android.volley.NoConnectionError: javax.net.ssl.SSLHandshakeException: Handshake failed
上班上的好好的,一个其他部门的同事来着手机来说,APP在他的手机上登录不进去。 实在是最近没有进行升级,在其他手机上也是好好的呀 ~~~ 然后他说他以前也是好的,最近手机升级了一次。一查看版本,Android6.0(小米4); 然后测试了一下三星6.0,Nexus6.0的结果都进不去,Android5.0,Android4.0的都 没有问题,所以应该是Android6.0Google对其进行
解决OKHttp3 报OKHTTP javax.net.ssl.SSLHandshakeException错误
一、概述 其实这篇文章理论上不限于okhttp去访问自签名的网站,不过接上篇博文了,就叫这个了。首先要了解的事,okhttp默认情况下是支持https协议的网站的,比如https://www.baidu.com,https://github.com/hongyangAndroid/okhttp-utils等,你可以直接通过okhttp请求试试。不过要注意的是,支持的https的网站基本都是C
SSLHandshakeException
javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure 引用来自“刘正阳”的评论 你这个是jdk导致的,jdk里面有一个jce的包,安全性机制导致的访问https会报错,官网上有替代的jar包,换掉就好了 引用来自“嘉树”的评论 牛逼啊 包在这里 http://
关于HttpClient在服务器端使用请求碰到的问题总结
static CloseableHttpClient client = null;     public static HttpEntity connectForResult(String url) {      HttpGet get = new HttpGet(url);            try {             client = HttpClientBuild