记录一个遇到的问题
httpclient 开启ssl后加代理代理死锁
最近做一个爬虫使用搜狗识图功能,由于ip问题需要增加代理,使用httpclient4.5.3 开启了ssl 代码由异步线程执行 在查看日志时候发现该线程执行一段时间后没有输出了 如图所示"aggregation_people" 线程
怀疑线程假死或者死锁了 但是我的代码全是单线程执行 并不存在共享资源这种情况
所以想查看当前这个线程的状态
ps -ef | grep ‘java’ 找出当前java进程pid jstack pid >> test.txt 将当前进程的所有线程执行状态打入test.txt文件 拉出来发现
"aggregation_people" #1656 daemon prio=5 os_prio=0 tid=0x00000000811b8000 nid=0xe28c runnable [0x000000008facd000]
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(SocketInputStream.java:116)
at java.net.SocketInputStream.read(SocketInputStream.java:171)
at java.net.SocketInputStream.read(SocketInputStream.java:141)
at sun.security.ssl.InputRecord.readFully(InputRecord.java:465)
at sun.security.ssl.InputRecord.read(InputRecord.java:503)
at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:983)
- locked <0x00000006cae97918> (a java.lang.Object)
at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1385)
- locked <0x00000006cae97928> (a java.lang.Object)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1413)
at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1397)
at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:396)
at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.upgrade(DefaultHttpClientConnectionOperator.java:193)
at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.upgrade(PoolingHttpClientConnectionManager.java:375)
at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:416)
at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:111)
at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:108)
at com.coocaa.video.sync.service.aggregationpeople.common.HttpClientUtils.requestSouGouHttpClient(HttpClientUtils.java:99)
at com.coocaa.video.sync.service.aggregationpeople.service.AggregationPeopleService.findSamePeopleByPhoto(AggregationPeopleService.java:486)
at com.coocaa.video.sync.service.aggregationpeople.service.AggregationPeopleService.aggregationSinglePeople(AggregationPeopleService.java:311)
at com.coocaa.video.sync.service.aggregationpeople.service.AggregationPeopleService.handleAggregationThirdSourcePeople(AggregationPeopleService.java:94)
at com.coocaa.video.sync.service.aggregationpeople.service.AggregationPeopleService.access$200(AggregationPeopleService.java:41)
at com.coocaa.video.sync.service.aggregationpeople.service.AggregationPeopleService$1.run(AggregationPeopleService.java:84)
at java.lang.Thread.run(Thread.java:748)
Locked ownable synchronizers:
- None
线程依旧在执行aggregation_people,但就是看不到输出日志
查询发现有以下问题 https://www.codeprj.com/blog/9618cd1.html
|