Tabnine Logo
OkHttpClient.connectTimeoutMillis
Code IndexAdd Tabnine to your IDE (free)

How to use
connectTimeoutMillis
method
in
okhttp3.OkHttpClient

Best Java code snippets using okhttp3.OkHttpClient.connectTimeoutMillis (Showing top 20 results out of 315)

origin: square/okhttp

@Override public int getConnectTimeout() {
 return client.connectTimeoutMillis();
}
origin: square/okhttp

 Response getResponseWithInterceptorChain() throws IOException {
  // Build a full stack of interceptors.
  List<Interceptor> interceptors = new ArrayList<>();
  interceptors.addAll(client.interceptors());
  interceptors.add(retryAndFollowUpInterceptor);
  interceptors.add(new BridgeInterceptor(client.cookieJar()));
  interceptors.add(new CacheInterceptor(client.internalCache()));
  interceptors.add(new ConnectInterceptor(client));
  if (!forWebSocket) {
   interceptors.addAll(client.networkInterceptors());
  }
  interceptors.add(new CallServerInterceptor(forWebSocket));

  Interceptor.Chain chain = new RealInterceptorChain(interceptors, null, null, null, 0,
    originalRequest, this, eventListener, client.connectTimeoutMillis(),
    client.readTimeoutMillis(), client.writeTimeoutMillis());

  return chain.proceed(originalRequest);
 }
}
origin: com.squareup.okhttp3/okhttp

 Response getResponseWithInterceptorChain() throws IOException {
  // Build a full stack of interceptors.
  List<Interceptor> interceptors = new ArrayList<>();
  interceptors.addAll(client.interceptors());
  interceptors.add(retryAndFollowUpInterceptor);
  interceptors.add(new BridgeInterceptor(client.cookieJar()));
  interceptors.add(new CacheInterceptor(client.internalCache()));
  interceptors.add(new ConnectInterceptor(client));
  if (!forWebSocket) {
   interceptors.addAll(client.networkInterceptors());
  }
  interceptors.add(new CallServerInterceptor(forWebSocket));

  Interceptor.Chain chain = new RealInterceptorChain(interceptors, null, null, null, 0,
    originalRequest, this, eventListener, client.connectTimeoutMillis(),
    client.readTimeoutMillis(), client.writeTimeoutMillis());

  return chain.proceed(originalRequest);
 }
}
origin: SonarSource/sonarqube

@Test
public void override_timeouts() {
 underTest = HttpConnector.newBuilder()
  .url(serverUrl)
  .readTimeoutMilliseconds(42)
  .connectTimeoutMilliseconds(74)
  .build();
 assertThat(underTest.okHttpClient().readTimeoutMillis()).isEqualTo(42);
 assertThat(underTest.okHttpClient().connectTimeoutMillis()).isEqualTo(74);
}
origin: SonarSource/sonarqube

@Test
public void test_default_settings() throws Exception {
 answerHelloWorld();
 underTest = HttpConnector.newBuilder().url(serverUrl).build();
 assertThat(underTest.baseUrl()).isEqualTo(serverUrl);
 GetRequest request = new GetRequest("api/issues/search").setMediaType(MediaTypes.PROTOBUF);
 WsResponse response = underTest.call(request);
 // verify default timeouts on client
 assertThat(underTest.okHttpClient().connectTimeoutMillis()).isEqualTo(HttpConnector.DEFAULT_CONNECT_TIMEOUT_MILLISECONDS);
 assertThat(underTest.okHttpClient().readTimeoutMillis()).isEqualTo(HttpConnector.DEFAULT_READ_TIMEOUT_MILLISECONDS);
 // verify response
 assertThat(response.hasContent()).isTrue();
 assertThat(response.content()).isEqualTo("hello, world!");
 // verify the request received by server
 RecordedRequest recordedRequest = server.takeRequest();
 assertThat(recordedRequest.getMethod()).isEqualTo("GET");
 assertThat(recordedRequest.getPath()).isEqualTo("/api/issues/search");
 assertThat(recordedRequest.getHeader("Accept")).isEqualTo(MediaTypes.PROTOBUF);
 assertThat(recordedRequest.getHeader("Accept-Charset")).isEqualTo("UTF-8");
 assertThat(recordedRequest.getHeader("User-Agent")).startsWith("okhttp/");
 // compression is handled by OkHttp
 assertThat(recordedRequest.getHeader("Accept-Encoding")).isEqualTo("gzip");
}
origin: com.palantir.remoting3/okhttp-clients

@Override
public int connectTimeoutMillis() {
  return delegate.connectTimeoutMillis();
}
origin: palantir/conjure-java-runtime

@Override
public int connectTimeoutMillis() {
  return delegate.connectTimeoutMillis();
}
origin: com.palantir.conjure.java.runtime/okhttp-clients

@Override
public int connectTimeoutMillis() {
  return delegate.connectTimeoutMillis();
}
origin: com.github.ljun20160606/okhttp-urlconnection

@Override public int getConnectTimeout() {
 return client.connectTimeoutMillis();
}
origin: com.squareup.okhttp3/okhttp-urlconnection

@Override public int getConnectTimeout() {
 return client.connectTimeoutMillis();
}
origin: apache/servicemix-bundles

@Override public int getConnectTimeout() {
 return client.connectTimeoutMillis();
}
origin: duzechao/OKHttpUtils

private HttpStream connect() throws RouteException, RequestException, IOException {
 boolean doExtensiveHealthChecks = !networkRequest.method().equals("GET");
 return streamAllocation.newStream(client.connectTimeoutMillis(),
   client.readTimeoutMillis(), client.writeTimeoutMillis(),
   client.retryOnConnectionFailure(), doExtensiveHealthChecks);
}
origin: com.netflix.feign/feign-okhttp

 @Override
 public feign.Response execute(feign.Request input, feign.Request.Options options)
   throws IOException {
  okhttp3.OkHttpClient requestScoped;
  if (delegate.connectTimeoutMillis() != options.connectTimeoutMillis()
    || delegate.readTimeoutMillis() != options.readTimeoutMillis()) {
    requestScoped = delegate.newBuilder()
        .connectTimeout(options.connectTimeoutMillis(), TimeUnit.MILLISECONDS)
        .readTimeout(options.readTimeoutMillis(), TimeUnit.MILLISECONDS)
        .build();
  } else {
   requestScoped = delegate;
  }
  Request request = toOkHttpRequest(input);
  Response response = requestScoped.newCall(request).execute();
  return toFeignResponse(response);
 }
}
origin: com.github.ljun20160606/okhttp

 Response getResponseWithInterceptorChain() throws IOException {
  // Build a full stack of interceptors.
  List<Interceptor> interceptors = new ArrayList<>();
  interceptors.addAll(client.interceptors());
  interceptors.add(retryAndFollowUpInterceptor);
  interceptors.add(new BridgeInterceptor(client.cookieJar()));
  interceptors.add(new CacheInterceptor(client.internalCache()));
  interceptors.add(new ConnectInterceptor(client));
  if (!forWebSocket) {
   interceptors.addAll(client.networkInterceptors());
  }
  interceptors.add(new CallServerInterceptor(forWebSocket));

  Interceptor.Chain chain = new RealInterceptorChain(interceptors, null, null, null, 0,
    originalRequest, this, eventListener, client.connectTimeoutMillis(),
    client.readTimeoutMillis(), client.writeTimeoutMillis());

  return chain.proceed(originalRequest);
 }
}
origin: Longi94/JavaSteam

@Test
public void httpClientConfigured() {
  assertNotNull(modifiedConfig.getHttpClient());
  assertEquals(60000L, modifiedConfig.getHttpClient().connectTimeoutMillis());
}
origin: launchdarkly/okhttp-eventsource

@Test
public void defaultClientWithProxy() {
 Proxy proxy = mock(java.net.Proxy.class);
 builder.proxy(proxy);
 builder.build();
 OkHttpClient client = builder.getClientBuilder().build();
 assertEquals(EventSource.DEFAULT_CONNECT_TIMEOUT_MS, client.connectTimeoutMillis());
 assertEquals(EventSource.DEFAULT_READ_TIMEOUT_MS, client.readTimeoutMillis());
 assertEquals(EventSource.DEFAULT_WRITE_TIMEOUT_MS, client.writeTimeoutMillis());
 assertEquals(proxy, client.proxy());
}
origin: launchdarkly/okhttp-eventsource

@Test
public void defaultClient() {
 builder.build();
 OkHttpClient client = builder.getClientBuilder().build();
 assertEquals(EventSource.DEFAULT_CONNECT_TIMEOUT_MS, client.connectTimeoutMillis());
 assertEquals(EventSource.DEFAULT_READ_TIMEOUT_MS, client.readTimeoutMillis());
 assertEquals(EventSource.DEFAULT_WRITE_TIMEOUT_MS, client.writeTimeoutMillis());
 assertNull(client.proxy());
}
origin: launchdarkly/okhttp-eventsource

@Test
public void defaultClientWithProxyHostAndPort() {
 String proxyHost = "http://proxy.example.com";
 int proxyPort = 8080;
 builder.proxy(proxyHost, proxyPort);
 builder.build();
 OkHttpClient client = builder.getClientBuilder().build();
 assertEquals(EventSource.DEFAULT_CONNECT_TIMEOUT_MS, client.connectTimeoutMillis());
 assertEquals(EventSource.DEFAULT_READ_TIMEOUT_MS, client.readTimeoutMillis());
 assertEquals(EventSource.DEFAULT_WRITE_TIMEOUT_MS, client.writeTimeoutMillis());
 Assert.assertNotNull(client.proxy());
 assertEquals(proxyHost + ":" + proxyPort, client.proxy().address().toString());
}
origin: launchdarkly/okhttp-eventsource

@Test
public void defaultClientWithCustomTimeouts() {
 int connectTimeout = 100;
 int readTimeout = 1000;
 int writeTimeout = 10000;
 builder.connectTimeoutMs(connectTimeout);
 builder.readTimeoutMs(readTimeout);
 builder.writeTimeoutMs(writeTimeout);
 builder.build();
 OkHttpClient client = builder.getClientBuilder().build();
 assertEquals(connectTimeout, client.connectTimeoutMillis());
 assertEquals(readTimeout, client.readTimeoutMillis());
 assertEquals(writeTimeout, client.writeTimeoutMillis());
}
origin: marklogic/java-client-api

@Test
public void testConfigurator() {
 ConfiguratorImpl configurator = new ConfiguratorImpl();
 DatabaseClientFactory.addConfigurator(configurator);
 DatabaseClient client = DatabaseClientFactory.newClient(
  Common.HOST, Common.PORT, new DigestAuthContext(Common.USER, Common.PASS));
 try {
  assertTrue("Factory did not apply custom configurator", configurator.isConfigured);
  OkHttpClient okClient = (OkHttpClient) client.getClientImplementation();
  assertEquals(testConnectTimeoutMillis, okClient.connectTimeoutMillis());
 } finally {
  client.release();
 }
}
okhttp3OkHttpClientconnectTimeoutMillis

Javadoc

Default connect timeout (in milliseconds).

Popular methods of OkHttpClient

  • newCall
    Prepares the request to be executed at some point in the future.
  • <init>
  • newBuilder
  • dispatcher
  • connectionPool
  • newWebSocket
    Uses request to connect a new web socket.
  • cache
  • interceptors
    Returns an immutable list of interceptors that observe the full span of each call: from before the c
  • readTimeoutMillis
    Default read timeout (in milliseconds).
  • proxy
  • networkInterceptors
    Returns an immutable list of interceptors that observe a single network request and response. These
  • cookieJar
  • networkInterceptors,
  • cookieJar,
  • sslSocketFactory,
  • writeTimeoutMillis,
  • followRedirects,
  • hostnameVerifier,
  • retryOnConnectionFailure,
  • authenticator,
  • connectionSpecs

Popular in Java

  • Making http post requests using okhttp
  • getApplicationContext (Context)
  • findViewById (Activity)
  • getSystemService (Context)
  • BufferedReader (java.io)
    Wraps an existing Reader and buffers the input. Expensive interaction with the underlying reader is
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Join (org.hibernate.mapping)
  • Top 17 Free Sublime Text 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