Tabnine Logo
OkHttpClient$Builder.connectTimeout
Code IndexAdd Tabnine to your IDE (free)

How to use
connectTimeout
method
in
okhttp3.OkHttpClient$Builder

Best Java code snippets using okhttp3.OkHttpClient$Builder.connectTimeout (Showing top 20 results out of 3,744)

origin: square/okhttp

public ConfigureTimeouts() throws Exception {
 client = new OkHttpClient.Builder()
   .connectTimeout(10, TimeUnit.SECONDS)
   .writeTimeout(10, TimeUnit.SECONDS)
   .readTimeout(30, TimeUnit.SECONDS)
   .build();
}
origin: square/okhttp

@Override public void setConnectTimeout(int timeoutMillis) {
 client = client.newBuilder()
   .connectTimeout(timeoutMillis, TimeUnit.MILLISECONDS)
   .build();
}
origin: spring-projects/spring-framework

/**
 * Set the underlying connect timeout in milliseconds.
 * A value of 0 specifies an infinite timeout.
 */
public void setConnectTimeout(int connectTimeout) {
  this.client = this.client.newBuilder()
      .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
      .build();
}
origin: crossoverJie/cim

/**
 * http client
 * @return okHttp
 */
@Bean
public OkHttpClient okHttpClient() {
  OkHttpClient.Builder builder = new OkHttpClient.Builder();
  builder.connectTimeout(30, TimeUnit.SECONDS)
      .readTimeout(10, TimeUnit.SECONDS)
      .writeTimeout(10,TimeUnit.SECONDS)
      .retryOnConnectionFailure(true);
  return builder.build();
}
origin: apache/nifi

protected InfluxDB makeConnection(String username, String password, String influxDbUrl, long connectionTimeout) {
  Builder builder = new OkHttpClient.Builder().connectTimeout(connectionTimeout, TimeUnit.SECONDS);
  if ( StringUtils.isBlank(username) || StringUtils.isBlank(password) ) {
    return InfluxDBFactory.connect(influxDbUrl, builder);
  } else {
    return InfluxDBFactory.connect(influxDbUrl, username, password, builder);
  }
}
origin: crossoverJie/cim

/**
 * http client
 * @return okHttp
 */
@Bean
public OkHttpClient okHttpClient() {
  OkHttpClient.Builder builder = new OkHttpClient.Builder();
  builder.connectTimeout(30, TimeUnit.SECONDS)
      .readTimeout(10, TimeUnit.SECONDS)
      .writeTimeout(10,TimeUnit.SECONDS)
      .retryOnConnectionFailure(true);
  return builder.build();
}
origin: jeasonlzy/okhttp-OkGo

private OkGo() {
  mDelivery = new Handler(Looper.getMainLooper());
  mRetryCount = 3;
  mCacheTime = CacheEntity.CACHE_NEVER_EXPIRE;
  mCacheMode = CacheMode.NO_CACHE;
  OkHttpClient.Builder builder = new OkHttpClient.Builder();
  HttpLoggingInterceptor loggingInterceptor = new HttpLoggingInterceptor("OkGo");
  loggingInterceptor.setPrintLevel(HttpLoggingInterceptor.Level.BODY);
  loggingInterceptor.setColorLevel(Level.INFO);
  builder.addInterceptor(loggingInterceptor);
  builder.readTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS);
  builder.writeTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS);
  builder.connectTimeout(OkGo.DEFAULT_MILLISECONDS, TimeUnit.MILLISECONDS);
  HttpsUtils.SSLParams sslParams = HttpsUtils.getSslSocketFactory();
  builder.sslSocketFactory(sslParams.sSLSocketFactory, sslParams.trustManager);
  builder.hostnameVerifier(HttpsUtils.UnSafeHostnameVerifier);
  okHttpClient = builder.build();
}
origin: graphhopper/graphhopper

/**
 * This method allows you to point the client to a different URL than the default one.
 *
 * @param serviceUrl Geocoding endpoint that is compatible with the GraphHopper geocoding API
 */
public GraphHopperGeocoding(String serviceUrl) {
  this.routeServiceUrl = serviceUrl;
  downloader = new OkHttpClient.Builder().
      connectTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS).
      readTimeout(DEFAULT_TIMEOUT, TimeUnit.MILLISECONDS).
      build();
  objectMapper = new ObjectMapper();
}
origin: graphhopper/graphhopper

private OkHttpClient getClientForRequest(GHRequest request) {
  OkHttpClient client = this.downloader;
  if (request.getHints().has(TIMEOUT)) {
    long timeout = request.getHints().getLong(TIMEOUT, DEFAULT_TIMEOUT);
    client = client.newBuilder()
        .connectTimeout(timeout, TimeUnit.MILLISECONDS)
        .readTimeout(timeout, TimeUnit.MILLISECONDS)
        .build();
  }
  return client;
}
origin: graphhopper/graphhopper

public GHMatrixAbstractRequester(String serviceUrl) {
  this(serviceUrl, new OkHttpClient.Builder().
      connectTimeout(5, TimeUnit.SECONDS).
      readTimeout(5, TimeUnit.SECONDS).build());
}
origin: graphhopper/graphhopper

private OkHttpClient getClientForRequest(GHGeocodingRequest request) {
  OkHttpClient client = this.downloader;
  if (request.hasTimeout()) {
    long timeout = request.getTimeout();
    client = client.newBuilder()
        .connectTimeout(timeout, TimeUnit.MILLISECONDS)
        .readTimeout(timeout, TimeUnit.MILLISECONDS)
        .build();
  }
  return client;
}
origin: graphhopper/graphhopper

public GHMatrixSyncRequester(String serviceUrl) {
  super(serviceUrl, new OkHttpClient.Builder().
      connectTimeout(15, TimeUnit.SECONDS).
      readTimeout(15, TimeUnit.SECONDS).build());
  initIgnore();
}
origin: amitshekhariitbhu/Fast-Android-Networking

public static OkHttpClient getDefaultClient() {
  return new OkHttpClient().newBuilder()
      .connectTimeout(60, TimeUnit.SECONDS)
      .readTimeout(60, TimeUnit.SECONDS)
      .writeTimeout(60, TimeUnit.SECONDS)
      .build();
}
origin: amitshekhariitbhu/Fast-Android-Networking

public static void setClientWithCache(Context context) {
  sHttpClient = new OkHttpClient().newBuilder()
      .cache(Utils.getCache(context, ANConstants.MAX_CACHE_SIZE, ANConstants.CACHE_DIR_NAME))
      .connectTimeout(60, TimeUnit.SECONDS)
      .readTimeout(60, TimeUnit.SECONDS)
      .writeTimeout(60, TimeUnit.SECONDS)
      .build();
}
origin: smuyyh/BookReader

@Provides
public OkHttpClient provideOkHttpClient() {
  LoggingInterceptor logging = new LoggingInterceptor(new Logger());
  logging.setLevel(LoggingInterceptor.Level.BODY);
  OkHttpClient.Builder builder = new OkHttpClient.Builder().connectTimeout(10, TimeUnit.SECONDS)
      .connectTimeout(20 * 1000, TimeUnit.MILLISECONDS)
      .readTimeout(20 * 1000, TimeUnit.MILLISECONDS)
      .retryOnConnectionFailure(true) // 失败重发
      .addInterceptor(new HeaderInterceptor())
      .addInterceptor(logging);
  return builder.build();
}
origin: org.springframework/spring-web

/**
 * Set the underlying connect timeout in milliseconds.
 * A value of 0 specifies an infinite timeout.
 */
public void setConnectTimeout(int connectTimeout) {
  this.client = this.client.newBuilder()
      .connectTimeout(connectTimeout, TimeUnit.MILLISECONDS)
      .build();
}
origin: Alluxio/alluxio

private static Builder initializeKodoClientConfig(UnderFileSystemConfiguration conf) {
 OkHttpClient.Builder builder = new OkHttpClient.Builder();
 Dispatcher dispatcher = new Dispatcher();
 dispatcher.setMaxRequests(conf.getInt(PropertyKey.UNDERFS_KODO_REQUESTS_MAX));
 builder.connectTimeout(conf.getMs(PropertyKey.UNDERFS_KODO_CONNECT_TIMEOUT), TimeUnit.SECONDS);
 return builder;
}
origin: apache/flink

public DatadogHttpClient(String dgApiKey) {
  if (dgApiKey == null || dgApiKey.isEmpty()) {
    throw new IllegalArgumentException("Invalid API key:" + dgApiKey);
  }
  apiKey = dgApiKey;
  client = new OkHttpClient.Builder()
    .connectTimeout(TIMEOUT, TimeUnit.SECONDS)
    .writeTimeout(TIMEOUT, TimeUnit.SECONDS)
    .readTimeout(TIMEOUT, TimeUnit.SECONDS)
    .build();
  seriesUrl = String.format(SERIES_URL_FORMAT, apiKey);
  validateUrl = String.format(VALIDATE_URL_FORMAT, apiKey);
  validateApiKey();
}
origin: square/okhttp

private OkHttpClient createClient() {
 OkHttpClient.Builder builder = new OkHttpClient.Builder();
 builder.followSslRedirects(followRedirects);
 if (connectTimeout != DEFAULT_TIMEOUT) {
  builder.connectTimeout(connectTimeout, SECONDS);
 }
 if (readTimeout != DEFAULT_TIMEOUT) {
  builder.readTimeout(readTimeout, SECONDS);
 }
 if (callTimeout != DEFAULT_TIMEOUT) {
  builder.callTimeout(callTimeout, SECONDS);
 }
 if (allowInsecure) {
  X509TrustManager trustManager = createInsecureTrustManager();
  SSLSocketFactory sslSocketFactory = createInsecureSslSocketFactory(trustManager);
  builder.sslSocketFactory(sslSocketFactory, trustManager);
  builder.hostnameVerifier(createInsecureHostnameVerifier());
 }
 if (verbose) {
  HttpLoggingInterceptor.Logger logger = System.out::println;
  builder.eventListenerFactory(new LoggingEventListener.Factory(logger));
 }
 return builder.build();
}
origin: prestodb/presto

public static void setupTimeouts(OkHttpClient.Builder clientBuilder, int timeout, TimeUnit unit)
{
  clientBuilder
      .connectTimeout(timeout, unit)
      .readTimeout(timeout, unit)
      .writeTimeout(timeout, unit);
}
okhttp3OkHttpClient$BuilderconnectTimeout

Javadoc

Sets the default connect timeout for new connections. A value of 0 means no timeout, otherwise values must be between 1 and Integer#MAX_VALUE when converted to milliseconds.

Popular methods of OkHttpClient$Builder

  • build
  • <init>
  • addInterceptor
  • readTimeout
    Sets the default read timeout for new connections. A value of 0 means no timeout, otherwise values m
  • writeTimeout
    Sets the default write timeout for new connections. A value of 0 means no timeout, otherwise values
  • addNetworkInterceptor
  • sslSocketFactory
    Sets the socket factory and trust manager used to secure HTTPS connections. If unset, the system def
  • cache
    Sets the response cache to be used to read and write cached responses.
  • hostnameVerifier
    Sets the verifier used to confirm that response certificates apply to requested hostnames for HTTPS
  • retryOnConnectionFailure
    Configure this client to retry or not when a connectivity problem is encountered. By default, this c
  • cookieJar
    Sets the handler that can accept cookies from incoming HTTP responses and provides cookies to outgoi
  • proxy
    Sets the HTTP proxy that will be used by connections created by this client. This takes precedence o
  • cookieJar,
  • proxy,
  • followRedirects,
  • proxyAuthenticator,
  • connectionPool,
  • connectionSpecs,
  • authenticator,
  • followSslRedirects,
  • dispatcher

Popular in Java

  • Reactive rest calls using spring rest template
  • onCreateOptionsMenu (Activity)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • startActivity (Activity)
  • FileWriter (java.io)
    A specialized Writer that writes to a file in the file system. All write requests made by calling me
  • Socket (java.net)
    Provides a client-side TCP socket.
  • PriorityQueue (java.util)
    A PriorityQueue holds elements on a priority heap, which orders the elements according to their natu
  • SortedMap (java.util)
    A map that has its keys ordered. The sorting is according to either the natural ordering of its keys
  • TimeUnit (java.util.concurrent)
    A TimeUnit represents time durations at a given unit of granularity and provides utility methods to
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • 21 Best IntelliJ Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now