From 8f942d6fe2db876a6ef3a9cd8cef9816570a1544 Mon Sep 17 00:00:00 2001 From: "yihua.huang" Date: Sun, 18 Dec 2016 06:56:01 +0800 Subject: [PATCH] =?UTF-8?q?#419=20=E4=BF=AE=E5=A4=8D=E6=8A=93=E5=8F=96http?= =?UTF-8?q?s=E9=93=BE=E6=8E=A5=E7=BA=BF=E7=A8=8B=E6=97=A0=E6=B3=95?= =?UTF-8?q?=E7=BB=93=E6=9D=9F=E5=AF=BC=E8=87=B4=E8=BF=9B=E7=A8=8B=E4=B8=80?= =?UTF-8?q?=E7=9B=B4=E8=BF=90=E8=A1=8C=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../us/codecraft/webmagic/downloader/HttpClientGenerator.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientGenerator.java b/webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientGenerator.java index 520d376..80a7e29 100644 --- a/webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientGenerator.java +++ b/webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientGenerator.java @@ -91,8 +91,9 @@ public class HttpClientGenerator { } - SocketConfig socketConfig = SocketConfig.custom().setSoKeepAlive(true).setTcpNoDelay(true).build(); + SocketConfig socketConfig = SocketConfig.custom().setSoTimeout(site.getTimeOut()).setSoKeepAlive(true).setTcpNoDelay(true).build(); httpClientBuilder.setDefaultSocketConfig(socketConfig); + connectionManager.setDefaultSocketConfig(socketConfig); if (site != null) { httpClientBuilder.setRetryHandler(new DefaultHttpRequestRetryHandler(site.getRetryTimes(), true)); }