Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-1613 Timeouts in protocol-httpclient when crawling same host with >2 threads

Julien Nioche237d8cac045d
diff --git a/CHANGES.txt b/CHANGES.txt
index a0f44582d..1bac47496 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -2,6 +2,8 @@ Nutch Change Log
Nutch Current Development
+* NUTCH-1613 Timeouts in protocol-httpclient when crawling same host with >2 threads (brian44 via jnioche)
+
* NUTCH-1766 Generator to unlock crawldb and remove tempdir if generate job fails (Diaa via jnioche)
* NUTCH-207 Bandwidth target for fetcher rather than a thread count (jnioche)
diff --git a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java
index ab21495cb..86830772b 100644
--- a/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java
+++ b/src/plugin/protocol-httpclient/src/java/org/apache/nutch/protocol/httpclient/Http.java
@@ -80,7 +80,7 @@ public class Http extends HttpBase {
private static boolean authRulesRead = false;
private static Configuration conf;
- int maxThreadsTotal = 10;
+ private int maxThreadsTotal = 10;
private String proxyUsername;
private String proxyPassword;
@@ -170,6 +170,10 @@ public class Http extends HttpBase {
params.setSendBufferSize(BUFFER_SIZE);
params.setReceiveBufferSize(BUFFER_SIZE);
params.setMaxTotalConnections(maxThreadsTotal);
+
+ //Also set max connections per host to maxThreadsTotal since all threads
+ //might be used to fetch from the same host - otherwise timeout errors can occur
+ params.setDefaultMaxConnectionsPerHost(maxThreadsTotal);
// executeMethod(HttpMethod) seems to ignore the connection timeout on the connection manager.
// set it explicitly on the HttpClient.