httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT_MILLIS);
private HttpClient createHttpClient() { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setExcludeCipherSuites(""); HttpClient client = new HttpClient(sslContextFactory); client.setFollowRedirects(false); client.setMaxConnectionsPerDestination(2); //You can set more restrictive timeouts per request, but not less, so // we set the maximum timeout of 1 hour here. client.setIdleTimeout(60 * 60 * 1000); try { client.start(); } catch (Exception e) { logger.error("Error building http client", e); } return client; }
@Provides public HttpClient getHttpClient() { HttpClient client = new HttpClient(); client.setFollowRedirects(false); client.setMaxConnectionsPerDestination(32); client.setConnectTimeout(100); client.setAddressResolutionTimeout(100); //You can set more restrictive timeouts per request, but not less, so // we set the maximum timeout of 1 hour here. client.setIdleTimeout(60 * 60 * 1000); try { client.start(); } catch (Exception e) { logger.error("Error building http client", e); } return client; }
private HttpClient createHttpClient() { //Allow ssl by default SslContextFactory sslContextFactory = new SslContextFactory(); //Don't exclude RSA because Sixt needs them, dammit! sslContextFactory.setExcludeCipherSuites(""); HttpClient client = new HttpClient(sslContextFactory); client.setFollowRedirects(false); client.setMaxConnectionsPerDestination(16); client.setRequestBufferSize(65536); client.setConnectTimeout(FeatureFlags.getHttpConnectTimeout(serviceProperties)); client.setAddressResolutionTimeout(FeatureFlags.getHttpAddressResolutionTimeout(serviceProperties)); //You can set more restrictive timeouts per request, but not less, so // we set the maximum timeout of 1 hour here. client.setIdleTimeout(60 * 60 * 1000); try { client.start(); } catch (Exception e) { logger.error("Error building http client", e); } return client; }
@Provides @Singleton public HttpClient provideHttpClient(ExecutorService executorService, @Named("httpClient.maxConnectionsQueued") Integer maxConnectionsQueued, @Named("httpClient.maxConnectionPerRoute") Integer maxConnectionPerRoute, @Named("httpClient.requestBufferSize") Integer requestBufferSize, @Named("httpClient.responseBufferSize") Integer responseBufferSize, @Named("httpClient.maxRedirects") Integer maxRedirects, @Named("httpClient.trustAllCertificates") Boolean trustAllCertificates) { try { SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setTrustAll(trustAllCertificates); HttpClient httpClient = new HttpClient(sslContextFactory); httpClient.setExecutor(executorService); httpClient.setMaxConnectionsPerDestination(maxConnectionsQueued); httpClient.setMaxRequestsQueuedPerDestination(maxConnectionPerRoute); httpClient.setRequestBufferSize(requestBufferSize); httpClient.setResponseBufferSize(responseBufferSize); httpClient.setMaxRedirects(maxRedirects); httpClient.start(); registerHttpClientShutdownHook(httpClient); return httpClient; } catch (Exception e) { System.out.println(Arrays.toString(e.getStackTrace())); throw new RuntimeException(e.getLocalizedMessage(), e); } }
@Override public HttpClient run() { if (logger.isDebugEnabled()) { if (endpoint == null) { logger.debug("creating http client for consumer {}", consumerName); } else { logger.debug("creating http client for consumer {}, endpoint {}", consumerName, endpoint); } } HttpClient httpClient = new HttpClient(createSslContextFactory(endpoint)); httpClient.setMaxConnectionsPerDestination(2); if (threadPool != null) { httpClient.setExecutor(threadPool); } else { final QueuedThreadPool queuedThreadPool = createThreadPool(consumerName, minThreadsCustom, maxThreadsCustom, keepAliveTimeoutCustom); httpClient.setExecutor(queuedThreadPool); } if (startClient) { try { httpClient.start(); } catch (Exception e) { logger.error("Could not start Jetty http client", e); throw new HttpClientInitializationException("Could not start Jetty http client", e); } } return httpClient; } });
private HttpClient createClient() throws Exception { int selectors = Math.max(1, Runtime.getRuntime().availableProcessors() / 2); HttpClient client = new HttpClient(new HttpClientTransportOverHTTP(selectors), new SslContextFactory(true)); client.setFollowRedirects(false); client.setCookieStore(new HttpCookieStore.Empty()); client.setMaxConnectionsPerDestination(256); client.setAddressResolutionTimeout(15000); client.setConnectTimeout(15000); client.setIdleTimeout(idleTimeout); client.setUserAgentField(null); client.start(); client.getContentDecoderFactories().clear(); return client; }
if (value == null) value = "256"; client.setMaxConnectionsPerDestination(Integer.parseInt(value));
if (value == null) value = "256"; client.setMaxConnectionsPerDestination(Integer.parseInt(value));
private HttpClient client() { HttpField agent = new HttpField("User-Agent", config.agent); HttpClient httpClient = new HttpClient(); httpClient.setFollowRedirects(false); httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST); httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST); httpClient.setUserAgentField(agent); httpClient.setCookieStore(new HttpCookieStore.Empty()); return httpClient; }
private HttpClient client() { HttpField agent = new HttpField("User-Agent", config.agent); // TODO: non-keepalived client connections HttpClient httpClient = new HttpClient(); httpClient.setFollowRedirects(false); httpClient.setMaxConnectionsPerDestination(MAX_CONNECTIONS_PER_DEST); httpClient.setMaxRequestsQueuedPerDestination(MAX_QUEUED_REQUESTS_PER_DEST); httpClient.setUserAgentField(agent); httpClient.setCookieStore(new HttpCookieStore.Empty()); return httpClient; }
httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT);
httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued()); httpClient.setConnectTimeout(CLIENT_CONNECT_TIMEOUT_MILLIS);
@Override protected void configureClient() { boolean addSslSupport = StringUtils.isNotEmpty(metadata.getKeyStorePath()) && StringUtils.isNotEmpty(metadata.getKeyStorePassword()); if(addSslSupport){ SslContextFactory sslContextFactory = new SslContextFactory(); sslContextFactory.setKeyStorePath(metadata.getKeyStorePath()); sslContextFactory.setKeyStorePassword(metadata.getKeyStorePassword()); boolean addTrustSupport = StringUtils.isNotEmpty(metadata.getTrustStorePath()) && StringUtils.isNotEmpty(metadata.getTrustStorePassword()); if(addTrustSupport){ sslContextFactory.setTrustStorePath(metadata.getTrustStorePath()); sslContextFactory.setTrustStorePassword(metadata.getTrustStorePassword()); }else{ sslContextFactory.setTrustAll(true); } httpClient = new HttpClient(sslContextFactory); } httpClient.setConnectTimeout(metadata.getConnectTimeout()); httpClient.setIdleTimeout(metadata.getIdleTimeout()); httpClient.setMaxConnectionsPerDestination(metadata.getMaxConnectionsPerAddress()); httpClient.setMaxRequestsQueuedPerDestination(metadata.getMaxQueueSizePerAddress()); httpClient.setFollowRedirects(followRedirects); try { httpClient.start(); } catch (Exception e) { throw new ClientException("failed to start jetty http client: " + e, e); } }
public HttpClient createClientForHttp1(String name) { ExecutorService executor = executorFactory.getExecutorService(name, configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_MONITORING)); HttpClient client = new HttpClient(createSslContextFactory()); client.setMaxConnectionsPerDestination(configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_MAX_CONNECTIONS_PER_DESTINATION)); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setExecutor(executor); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
public HttpClient createClientForHttp1(String name) { ExecutorService executor = executorFactory.getExecutorService(name, configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_SIZE), configFactory.getBooleanProperty(CONSUMER_HTTP_CLIENT_THREAD_POOL_MONITORING)); HttpClient client = new HttpClient(createSslContextFactory()); client.setMaxConnectionsPerDestination(configFactory.getIntProperty(CONSUMER_HTTP_CLIENT_MAX_CONNECTIONS_PER_DESTINATION)); client.setMaxRequestsQueuedPerDestination(configFactory.getIntProperty(CONSUMER_INFLIGHT_SIZE)); client.setExecutor(executor); client.setCookieStore(new HttpCookieStore.Empty()); return client; }
this.httpClient.setFollowRedirects(options.followRedirects); this.httpClient.setConnectTimeout(options.connectionTimeoutMillis); this.httpClient.setMaxConnectionsPerDestination(options.maxConnectionsPerDestination); this.httpClient.setCookieStore(new HttpCookieStore.Empty()); if(options.proxyHost != null) {
httpClient.setMaxConnectionsPerDestination(config.getMaxConnectionsPerServer()); httpClient.setMaxRequestsQueuedPerDestination(config.getMaxRequestsQueuedPerDestination());
httpClient.setMaxConnectionsPerDestination(config.getMaxConnectionsPerServer());