httpclientorg.apache.http.nohttpresponseexceptionhost端口failedtorespond错误原因和解决方法

合集下载
相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

httpclient org.apache.http.NoHttpResponseException host 端口failed to respond 错误原因和解决方法

import com.google.api.client.http.ByteArrayContent; import com.google.api.client.http.GenericUrl;

import

com.google.api.client.http.HttpBackOffUnsuccessfulRespo nseHandler;

import com.google.api.client.http.HttpContent;

import com.google.api.client.http.HttpHeaders;

import com.google.api.client.http.HttpRequest;

import com.google.api.client.http.HttpRequestFactory; import com.google.api.client.http.HttpResponse;

import com.google.api.client.http.HttpStatusCodes; import com.google.api.client.http.HttpTransport;

import

com.google.api.client.http.apache.ApacheHttpTransport; import com.google.api.client.util.BackOff;

import java.io.IOException;

import java.io.InputStream;

import .ProxySelector;

import java.util.Map;

import java.util.Timer;

import java.util.TimerTask;

import java.util.concurrent.TimeUnit;

import javax.annotation.PreDestroy;

import lombok.Data;

import lombok.extern.slf4j.Slf4j;

import org.apache.http.HeaderElement;

import org.apache.http.HeaderElementIterator;

import org.apache.http.HttpHost;

import org.apache.http.conn.ClientConnectionManager; import

org.apache.http.conn.ConnectionKeepAliveStrategy; import

org.apache.http.conn.params.ConnManagerParams; import org.apache.http.conn.params.ConnPerRouteBean; import org.apache.http.conn.scheme.PlainSocketFactory; import org.apache.http.conn.scheme.Scheme;

import org.apache.http.conn.scheme.SchemeRegistry; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.impl.client.DefaultHttpClient; import

org.apache.http.impl.client.DefaultHttpRequestRetryHandl

er;

import

org.apache.http.impl.conn.ProxySelectorRoutePlanner; import

org.apache.http.impl.conn.tsccm.ThreadSafeClientConnM anager;

import

org.apache.http.message.BasicHeaderElementIterator; import org.apache.http.params.BasicHttpParams;

import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams;

import org.apache.http.protocol.HTTP;

import org.apache.http.protocol.HttpContext;

/**

* @author Li Sheng

*/

@Slf4j

public class HttpClientUtils {

private static HttpRequestFactory requestFactory;

private static HttpTransport httpTransport;

private static final String CONTENT_TYPE_JSON = "application/json";

private static final int CACHE_SIZE = 4096;

static {

HttpParams params = new BasicHttpParams();

HttpConnectionParams.setStaleCheckingEnabled(params, false);

HttpConnectionParams.setSocketBufferSize(params, 245760); // 8k(8192) * 30

ConnManagerParams.setMaxTotalConnections(params, 400);

ConnManagerParams.setMaxConnectionsPerRoute(para ms, new ConnPerRouteBean(200));

相关文档
最新文档