org.vertx.java.core.http.HttpClient.setConnectTimeout()方法的使用及代码示例

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

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

HttpClient.setConnectTimeout介绍

[英]Set the connect timeout in milliseconds.
[中]以毫秒为单位设置连接超时。

代码示例

代码示例来源:origin: com.englishtown/vertx-mod-when

protected <T> HttpClient createClient(URI url, final Deferred<T> d) {
  if (url == null) throw new IllegalArgumentException("url is null");
  if (!url.isAbsolute()) throw new IllegalArgumentException("url must be absolute");
  int port = (url.getPort() > 0) ? url.getPort() : 80;
  return vertx.createHttpClient()
      .setHost(url.getHost())
      .setPort(port)
      .setConnectTimeout(CONNECT_TIMEOUT)
      .exceptionHandler(t -> d.reject(t));
}

代码示例来源:origin: vert-x/mod-lang-php

/**
 * Sets the connection timeout.
 */
public HttpClient connectTimeout(Env env, NumberValue timeout) {
 PhpTypes.assertNotNull(env, timeout, "Timeout to Vertx\\Http\\HttpClient::connectTimeout() must be an integer.");
 client.setConnectTimeout(timeout.toInt());
 return this;
}

代码示例来源:origin: boonproject/boon

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: boonproject/boon

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: io.fastjson/etcd-client

private void connect() {
  int index = this.currentIndex.get();
  int oldIndex = index;
  if (index + 1 == hosts.length) {
    index = 0;
  } else {
    index++;
  }
  if (this.currentIndex.compareAndSet(oldIndex, index)) {
    final URI uri = this.hosts[index];
    logger.info("Connecting to ", uri);
    httpClient = vertx.createHttpClient().setHost(uri.getHost()).setPort(uri.getPort())
        .setConnectTimeout(this.timeOutInMilliseconds).setMaxPoolSize(poolSize);
    httpClient.exceptionHandler(new Handler<Throwable>() {
      @Override
      public void handle(Throwable throwable) {
        if (throwable instanceof ConnectException) {
          closed.set(true);
        } else {
          logger.error(throwable, "Unable to connect to ", uri);
        }
      }
    });
    configureSSL(httpClient);
    closed.set(false);
  }
}

代码示例来源:origin: jboss-fuse/fabric8

client.setConnectTimeout( connectionTimeout );

相关文章