title: Why do I get java.net.SocketTimeoutException with OkHttp?
body: <p>Here's my configuration:</p>
  
  <pre><code>httpClient = new OkHttpClient.Builder()
          .callTimeout(Duration.ofSeconds(60))
          .connectTimeout(Duration.ofSeconds(60))
          .readTimeout(Duration.ofSeconds(60))
          .writeTimeout(Duration.ofSeconds(60))
          .build();
  </code></pre>
  
  <p>I have a multithreaded process that uses this client. <strong>Few seconds</strong> after running I'm getting:</p>
  
  <blockquote>
    <p><strong>java.net.SocketTimeoutException: timeout</strong><br>
    at okio.Okio$4.newTimeoutException(Okio.java:232)<br>
    at okio.AsyncTimeout.exit(AsyncTimeout.java:286)<br>
    at okio.AsyncTimeout$2.read(AsyncTimeout.java:241)<br>
    at okio.RealBufferedSource.indexOf(RealBufferedSource.java:358)</p>
  </blockquote>
  
  <p>How is it possible if I configured the timeouts to 60 seconds?</p>
  
  <p><strong>EDIT:</strong><br>
  Even adding a custom dispatcher didn't help:</p>
  
  <pre><code>Dispatcher dispatcher = new Dispatcher();
  dispatcher.setMaxRequests(Integer.MAX_VALUE);
  dispatcher.setMaxRequestsPerHost(Integer.MAX_VALUE);
  </code></pre>
  
  <p><strong>TECHNICAL DETAILS:</strong><br>
  As opposed to what I've said, I'm running both the client and the server on Linux machines:</p>
  
  <blockquote>
    <p>Client's machine: net.ipv4.tcp_keepalive_time = 7200<br>
    Server's machine: net.ipv4.tcp_keepalive_time = 7200</p>
  </blockquote>