0
私は、以下の方法でのApacheのHttpClient 3.1とWebサービス・リクエストを実行しています:のApacheのHttpClient 3.1ソケットタイムアウト
private MultiThreadedHttpConnectionManager cm = null;
private HttpClient client = null;
// Setting up connection manager during init process
cm = new MultiThreadedHttpConnectionManager();
int connectionTimeout = 12000; // it actually comes from config file, but this is the current value
cm.getParams().setConnectionTimeout(connectionTimeout);
cm.getParams().setTcpNoDelay(true);
client = new HttpClient(cm);
// method is prepared with request data earlier
int socketTimeout = 30000; // it actually comes from config file, but this is the current value
method.getParams().setSoTimeout(socketTimeout);
method.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new DefaultHttpMethodRetryHandler(0, false));
logger.info("Starting request");
int statusCode = client.executeMethod(method);
logger.info("StatusCode = " + statusCode);
String response = method.getResponseBodyAsString();
logger.info("Response = " + response);
ログファイルのタイムスタンプは、以下の通りである:
2017-05-02 08:50:03,881 Starting request
2017-05-02 08:50:16,680 StatusCode = 200
2017-05-02 08:50:46,708 java.net.SocketTimeoutException
だから、たとえ接続タイムアウトは12秒に設定され、executeMethodコールはほぼ13秒かかりました。私はこれについて混乱しています。ドキュメントはここではっきりしていないので、executeMethodとgetResponseBodyAsStringの両方でソケットタイムアウトを個別に使用すると言っても間違いありませんか?だから、この場合、ソケットのタイムアウトは30秒なので、理論的には実行には60秒かかることがありますか?
ありがとうございます。 –