@Override public HttpClientConnectionManager create(final HttpClientSettings settings) { ConnectionSocketFactory sslsf = getPreferredSocketFactory(settings); final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager( createSocketFactoryRegistry(sslsf), null, DefaultSchemePortResolver.INSTANCE, new DelegatingDnsResolver(settings.getDnsResolver()), settings.getConnectionPoolTTL(), TimeUnit.MILLISECONDS); cm.setValidateAfterInactivity(settings.getValidateAfterInactivityMillis()); cm.setDefaultMaxPerRoute(settings.getMaxConnections()); cm.setMaxTotal(settings.getMaxConnections()); cm.setDefaultSocketConfig(buildSocketConfig(settings)); cm.setDefaultConnectionConfig(buildConnectionConfig(settings)); return cm; }
private PoolingHttpClientConnectionManager createPoolingConnectionManager() { PoolingHttpClientConnectionManager connManager = new PoolingHttpClientConnectionManager(getSocketFactoryRegistry(), getConnectionFactory()); connManager.setDefaultSocketConfig(createSocketConfig()); connManager.setDefaultConnectionConfig(createConnectionConfig()); if (maxTotalConnections != 0) { connManager.setMaxTotal(maxTotalConnections); connManager.setDefaultMaxPerRoute(defaultMaxConnectionsPerRoute); } return connManager; }
ConnectionConfig.custom().setMalformedInputAction(CodingErrorAction.IGNORE) .setUnmappableInputAction(CodingErrorAction.IGNORE).setCharset(Consts.UTF_8).build(); connManager.setDefaultConnectionConfig(connectionConfig); connManager.setMaxTotal(500); connManager.setDefaultMaxPerRoute(300);
@Override public HttpClientConnectionManager create(final HttpClientSettings settings) { ConnectionSocketFactory sslsf = getPreferredSocketFactory(settings); final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager( createSocketFactoryRegistry(sslsf), null, DefaultSchemePortResolver.INSTANCE, new DelegatingDnsResolver(settings.getDnsResolver()), settings.getConnectionPoolTTL(), TimeUnit.MILLISECONDS); cm.setValidateAfterInactivity(settings.getValidateAfterInactivityMillis()); cm.setDefaultMaxPerRoute(settings.getMaxConnections()); cm.setMaxTotal(settings.getMaxConnections()); cm.setDefaultSocketConfig(buildSocketConfig(settings)); cm.setDefaultConnectionConfig(buildConnectionConfig(settings)); return cm; }
@Nonnull public HttpClientConnectionManager createConnectionManager (@Nonnull final LayeredConnectionSocketFactory aSSLFactory) { final Registry <ConnectionSocketFactory> aConSocketRegistry = RegistryBuilder.<ConnectionSocketFactory> create () .register ("http", PlainConnectionSocketFactory.getSocketFactory ()) .register ("https", aSSLFactory) .build (); final DnsResolver aDNSResolver = createDNSResolver (); final PoolingHttpClientConnectionManager aConnMgr = new PoolingHttpClientConnectionManager (aConSocketRegistry, aDNSResolver); aConnMgr.setDefaultMaxPerRoute (100); aConnMgr.setMaxTotal (200); aConnMgr.setValidateAfterInactivity (1000); final ConnectionConfig aConnectionConfig = createConnectionConfig (); aConnMgr.setDefaultConnectionConfig (aConnectionConfig); return aConnMgr; }
protected CloseableHttpClient initHttpClient() { HttpClientBuilder cb = HttpClientBuilder.create(); //TODO : small buffer size will cause socket closed when reading response entity? PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(getDefaultRegistry()); //cm.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSize(1024 * 1024).build()); cm.setMaxTotal(maxConnectionTotal); cm.setDefaultMaxPerRoute(maxConnectionPerRoute); if(bufferSize > 0) { ConnectionConfig cc = ConnectionConfig.copy(ConnectionConfig.DEFAULT).setBufferSize(bufferSize).build(); cm.setDefaultConnectionConfig(cc); } cb.setRetryHandler(new DefaultHttpRequestRetryHandler()); cb.setConnectionManager(cm); cb.setDefaultRequestConfig(requestConfig); cb.disableCookieManagement(); return cb.build(); }
poolingManager.setDefaultConnectionConfig(defaultConnectionConfig);
connManager.setDefaultConnectionConfig(connectionConfig);
connManager.setDefaultConnectionConfig(connConfig); return connManager;
protected HttpClient createHttpClient() { PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager(); connectionManager.setDefaultMaxPerRoute(200); connectionManager.setMaxTotal(200); connectionManager.setDefaultConnectionConfig(ConnectionConfig .custom() .setCharset(Charset.forName("UTF-8")) .build()); connectionManager.setDefaultSocketConfig(SocketConfig.custom().setTcpNoDelay(true).build()); // Need to work out a good value for the following: // threadSafeClientConnManager.setValidateAfterInactivity(); RequestConfig requestConfig = RequestConfig.custom().build(); return HttpClientBuilder .create() .setConnectionManager(connectionManager) .setUserAgent(String.format("%s/%s java/%s", CLIENT_NAME, CLIENT_VERSION, JAVA_VERSION)) .setDefaultRequestConfig(requestConfig) .useSystemProperties() .build(); }
protected HttpClient createDefaultHttpClient() { HttpClientBuilder cb = HttpClientBuilder.create(); //TODO : small buffer size will cause socket closed when reading response entity? PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager(getDefaultRegistry(), this.dnsResolver); cm.setDefaultConnectionConfig(ConnectionConfig.custom().setBufferSize(1024 * 1024).build()); cb.setConnectionManager(cm); cb.setDefaultCookieStore(this.cookieStore); cb.setRedirectStrategy(new DefaultRedirectStrategy() { @Override public boolean isRedirected(HttpRequest request, HttpResponse response, HttpContext context) throws ProtocolException { if(!autoRedirect){ return false; } return super.isRedirected(request, response, context); } }); return cb.build(); }
private PoolingHttpClientConnectionManager getConnectionManager() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException { RegistryBuilder<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()); if (properties.getSsl()) { registry.register("https", new SSLConnectionSocketFactory(getSSLContext())); } //noinspection resource PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( registry.build(), null, null, new IpVersionPriorityResolver(), properties.getTimeToLiveMillis(), TimeUnit.MILLISECONDS ); connectionManager.setDefaultMaxPerRoute(properties.getDefaultMaxPerRoute()); connectionManager.setMaxTotal(properties.getMaxTotal()); connectionManager.setDefaultConnectionConfig(getConnectionConfig()); return connectionManager; }
private PoolingHttpClientConnectionManager getConnectionManager() throws CertificateException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException, IOException { RegistryBuilder<ConnectionSocketFactory> registry = RegistryBuilder.<ConnectionSocketFactory>create() .register("http", PlainConnectionSocketFactory.getSocketFactory()); if (properties.getSsl()) { registry.register("https", new SSLConnectionSocketFactory(getSSLContext())); } //noinspection resource PoolingHttpClientConnectionManager connectionManager = new PoolingHttpClientConnectionManager( registry.build(), null, null, new IpVersionPriorityResolver(), properties.getTimeToLiveMillis(), TimeUnit.MILLISECONDS ); connectionManager.setDefaultMaxPerRoute(properties.getDefaultMaxPerRoute()); connectionManager.setMaxTotal(properties.getMaxTotal()); connectionManager.setDefaultConnectionConfig(getConnectionConfig()); return connectionManager; }
connManager = new PoolingHttpClientConnectionManager(registry); connManager.setDefaultConnectionConfig(connConfig); connManager.setDefaultSocketConfig(socketConfig);
ConnectionConfig connectionConfig = ConnectionConfig.custom().setMalformedInputAction(CodingErrorAction.IGNORE) .setUnmappableInputAction(CodingErrorAction.IGNORE).setCharset(Consts.UTF_8).build(); connManager.setDefaultConnectionConfig(connectionConfig); return connManager; } catch (Exception e) {
if ( connectionConfig != null ) poolingMgr.setDefaultConnectionConfig( connectionConfig );
@Override public HttpClientConnectionManager create(final HttpClientSettings settings) { ConnectionSocketFactory sslsf = getPreferredSocketFactory(settings); final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager( createSocketFactoryRegistry(sslsf), null, DefaultSchemePortResolver.INSTANCE, new DelegatingDnsResolver(settings.getDnsResolver()), settings.getConnectionPoolTTL(), TimeUnit.MILLISECONDS); cm.setDefaultMaxPerRoute(settings.getMaxConnections()); cm.setMaxTotal(settings.getMaxConnections()); cm.setDefaultSocketConfig(buildSocketConfig(settings)); cm.setDefaultConnectionConfig(buildConnectionConfig(settings)); return cm; }
.setUnmappableInputAction(CodingErrorAction.IGNORE).setCharset(Consts.UTF_8) .setMessageConstraints(messageConstraints).build(); connManager.setDefaultConnectionConfig(connectionConfig); connManager.setMaxTotal(200); connManager.setDefaultMaxPerRoute(20);
@Override public HttpClientConnectionManager create(final HttpClientSettings settings) { ConnectionSocketFactory sslsf = getPreferredSocketFactory(settings); final PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager( createSocketFactoryRegistry(sslsf), null, DefaultSchemePortResolver.INSTANCE, new DelegatingDnsResolver(settings.getDnsResolver()), settings.getConnectionPoolTTL(), TimeUnit.MILLISECONDS); cm.setValidateAfterInactivity(settings.getValidateAfterInactivityMillis()); cm.setDefaultMaxPerRoute(settings.getMaxConnections()); cm.setMaxTotal(settings.getMaxConnections()); cm.setDefaultSocketConfig(buildSocketConfig(settings)); cm.setDefaultConnectionConfig(buildConnectionConfig(settings)); return cm; }
.setBufferSize(clientContext.connection().bufferSize()) .build(); connectionManager.setDefaultConnectionConfig(connectionConfig);