org.eclipse.jetty.client.HttpClient.setIdleTimeout()方法的使用及代码示例

x33g5p2x  于2022-01-20 转载在 其他  
字(7.7k)|赞(0)|评价(0)|浏览(245)

本文整理了Java中org.eclipse.jetty.client.HttpClient.setIdleTimeout()方法的一些代码示例,展示了HttpClient.setIdleTimeout()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpClient.setIdleTimeout()方法的具体详情如下:
包路径:org.eclipse.jetty.client.HttpClient
类名称:HttpClient
方法名:setIdleTimeout

HttpClient.setIdleTimeout介绍

暂无

代码示例

代码示例来源:origin: apache/incubator-druid

httpClient.setIdleTimeout(config.getReadTimeout().getMillis());
httpClient.setMaxConnectionsPerDestination(config.getNumConnections());
httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());

代码示例来源:origin: sixt/ja-micro

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;
}

代码示例来源:origin: sixt/ja-micro

@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;
}

代码示例来源:origin: sixt/ja-micro

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;
}

代码示例来源:origin: org.eclipse.jetty.websocket/websocket-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);
}

代码示例来源:origin: danielflower/app-runner

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;
}

代码示例来源:origin: org.scalatra.socketio-java/socketio-core

@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();
}

代码示例来源:origin: tadglines/Socket.IO-Java

@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();
}

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

client.setIdleTimeout(Long.parseLong(t));

代码示例来源:origin: org.apache.pulsar/pulsar-proxy

if (value == null)
  value = "30000";
client.setIdleTimeout(Long.parseLong(value));

代码示例来源:origin: org.eclipse.jetty.aggregate/jetty-all-server

_client.setIdleTimeout(Long.parseLong(_idleTimeout));

代码示例来源:origin: org.eclipse.jetty/jetty-proxy

if (value == null)
  value = "30000";
client.setIdleTimeout(Long.parseLong(value));

代码示例来源:origin: io.druid/druid-server

httpClient.setIdleTimeout(config.getReadTimeout().getMillis());
httpClient.setMaxConnectionsPerDestination(config.getNumConnections());
httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());

代码示例来源:origin: org.apache.druid/druid-server

httpClient.setIdleTimeout(config.getReadTimeout().getMillis());
httpClient.setMaxConnectionsPerDestination(config.getNumConnections());
httpClient.setMaxRequestsQueuedPerDestination(config.getNumRequestsQueued());

代码示例来源:origin: com.cisco.oss.foundation/http-client-jetty

@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);
  }
}

代码示例来源:origin: org.attribyte/attribyte-http

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));

代码示例来源:origin: allegro/hermes

@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();
}

代码示例来源:origin: airlift/airlift

httpClient.setIdleTimeout(idleTimeoutMillis);
httpClient.setConnectTimeout(config.getConnectTimeout().toMillis());
httpClient.setAddressResolutionTimeout(config.getConnectTimeout().toMillis());

代码示例来源:origin: com.proofpoint.platform/http-client

httpClient.setIdleTimeout(idleTimeoutMillis);
httpClient.setConnectTimeout(config.getConnectTimeout().toMillis());
httpClient.setAddressResolutionTimeout(config.getConnectTimeout().toMillis());

相关文章

HttpClient类方法