• webmagic框架protocol_version问题处理


    异常描述:

     1 javax.net.ssl.SSLException: Received fatal alert: protocol_version
     2     at sun.security.ssl.Alerts.getSSLException(Alerts.java:208)
     3     at sun.security.ssl.Alerts.getSSLException(Alerts.java:154)
     4     at sun.security.ssl.SSLSocketImpl.recvAlert(SSLSocketImpl.java:2020)
     5     at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1127)
     6     at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1367)
     7     at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1395)
     8     at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1379)
     9     at org.apache.http.conn.ssl.SSLConnectionSocketFactory.createLayeredSocket(SSLConnectionSocketFactory.java:394)
    10     at org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:353)
    11     at org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:141)
    12     at org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:353)
    13     at org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:380)
    14     at org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:236)
    15     at org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:184)
    16     at org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:88)
    17     at org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
    18     at org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:184)
    19     at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:82)
    20     at us.codecraft.webmagic.downloader.HttpClientDownloader.download(HttpClientDownloader.java:85)
    21     at us.codecraft.webmagic.Spider.processRequest(Spider.java:404)
    22     at us.codecraft.webmagic.Spider.access$000(Spider.java:61)
    23     at us.codecraft.webmagic.Spider$1.run(Spider.java:320)
    24     at us.codecraft.webmagic.thread.CountableThreadPool$1.run(CountableThreadPool.java:74)
    25     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    26     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    27     at java.lang.Thread.run(Thread.java:748)

    原因:webmagic默认的HttpClient只会用TLSv1去请求,对于某些只支持TLS1.2的站点(例如https://juejin.im/) ,就会报错;

    解决方法:https://github.com/code4craft/webmagic/issues/701

  • 相关阅读:
    JavaScript基础
    WordPress站点绑定多个域名
    linux下如何把php升级到5.6
    ansible shell 之运行后台程序
    Redhat7 开机启动服务
    模拟jenkins通过shell给ansible传入变量
    ansible-playbook权限提升多种方式
    ansible删除目录下所有内容
    ansible 文件和目录操作
    linux 用户和组管理
  • 原文地址:https://www.cnblogs.com/mxh-java/p/15440272.html
Copyright © 2020-2023  润新知