httpClient.setIdleTimeout(config.getReadTimeout().getMillis()); httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());
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; }
/** * Set the max idle timeout for new connections. * <p> * Existing connections will not have their max idle timeout adjusted. * * @param ms the timeout in milliseconds */ public void setMaxIdleTimeout(long ms) { getPolicy().setIdleTimeout(ms); this.httpClient.setIdleTimeout(ms); }
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; }
@Override public void connect() { if (state != ConnectionState.CLOSED) { throw new IllegalStateException("Not CLOSED!"); } state = ConnectionState.CONNECTING; client = new HttpClient(); client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); client.setIdleTimeout(30*1000); //30 seconds try { client.start(); } catch (Exception e) { client = null; _disconnect(DisconnectReason.CONNECT_FAILED, "Failed to initialize"); return; } doGet(); }
@Override public void connect() { if (state != ConnectionState.CLOSED) { throw new IllegalStateException("Not CLOSED!"); } state = ConnectionState.CONNECTING; client = new HttpClient(); client.setConnectorType(HttpClient.CONNECTOR_SELECT_CHANNEL); client.setIdleTimeout(30*1000); //30 seconds try { client.start(); } catch (Exception e) { client = null; _disconnect(DisconnectReason.CONNECT_FAILED, "Failed to initialize"); return; } doGet(); }
client.setIdleTimeout(Long.parseLong(t));
if (value == null) value = "30000"; client.setIdleTimeout(Long.parseLong(value));
_client.setIdleTimeout(Long.parseLong(_idleTimeout));
if (value == null) value = "30000"; client.setIdleTimeout(Long.parseLong(value));
httpClient.setIdleTimeout(config.getReadTimeout().getMillis()); httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());
httpClient.setIdleTimeout(config.getReadTimeout().getMillis()); httpClient.setMaxConnectionsPerDestination(config.getNumConnections()); httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());
@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); } }
this.httpClient.setRequestBufferSize(options.requestBufferSize); this.httpClient.setResponseBufferSize(options.responseBufferSize); this.httpClient.setIdleTimeout(options.getIntProperty("idleTimeout", 0)); this.httpClient.setAddressResolutionTimeout(options.getIntProperty("addressResolutionTimeout", 15000)); this.httpClient.setMaxRedirects(options.getIntProperty("maxRedirects", 8));
@BeforeClass public static void setupEnvironment() throws Exception { wireMockServer = new WireMockServer(ENDPOINT_PORT); wireMockServer.start(); client = new HttpClient(); client.setCookieStore(new HttpCookieStore.Empty()); client.setConnectTimeout(1000); client.setIdleTimeout(1000); client.start(); }
httpClient.setIdleTimeout(idleTimeoutMillis); httpClient.setConnectTimeout(config.getConnectTimeout().toMillis()); httpClient.setAddressResolutionTimeout(config.getConnectTimeout().toMillis());
httpClient.setIdleTimeout(idleTimeoutMillis); httpClient.setConnectTimeout(config.getConnectTimeout().toMillis()); httpClient.setAddressResolutionTimeout(config.getConnectTimeout().toMillis());