title: What's the different between OKHttp3 3.14.9 and 4.9.2? It causes SocketException with same code
body: <p>My App was using OKHttp3 3.14.9 before. It was normal to call &quot;AAA&quot; API and then call &quot;BBB&quot; API immediately. After upgrade to 4.9.2, I didn't change any code, except required change for <a href="https://square.github.io/okhttp/changelogs/upgrading_to_okhttp_4/" rel="nofollow noreferrer">upgrading to OKHttp4</a>. Problem occurred. &quot;AAA&quot; calling was return 200. Then SocketException: Broken pipe and IOException: unexpected end of stream on Connection appeared during &quot;BBB&quot; API calling. The request didn't send to server. I used Charles to provide this. I try to add</p>
  <pre><code>.header(&quot;Connection&quot;, &quot;close&quot;)
  </code></pre>
  <p>to fix this problem. This approach seems to solve the problem. But I want to know the root cause and make sure it won't happen in sometimes.</p>
  <p>Base on Charles, I found that both versions are the same except &quot;Session Resumed&quot; and &quot;Kept Alive&quot;  in overview. The &quot;Session Resumed&quot; and &quot;Kept Alive&quot; were &quot;No&quot; in 3.14.9 version. But the &quot;Session Resumed&quot; was &quot;Yes&quot; in 4.9.2 version. In 4.9.2 devDebug version, &quot;Session Resumed&quot; shows &quot;N/A(Connection kept alive)&quot; and &quot;Yes&quot; in &quot;Kept Alive&quot;.</p>
  <p>My OKHttpClient is</p>
  <pre><code>val okHttpClientBuilder = OkHttpClient.Builder()
  okHttpClientBuilder.readTimeout(60, TimeUnit.SECONDS)
  .connectTimeout(60, TimeUnit.SECONDS)
  .cookieJar(WebkitCookieManagerProxy())
  .followRedirects(false)
  .retryOnConnectionFailure(false).build()
  </code></pre>
  <p>Here's the request and response</p>
  <pre><code>2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: --&gt; POST https://www.xxxxx.com/xxxx/xxxx/xxx/AAA http/1.1
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: Cache-Control: no-cache
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: Content-Type: application/json; charset=UTF-8
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: Content-Length: 4647082
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: Host: www.xxxx.com
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: Connection: Keep-Alive
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: Accept-Encoding: gzip
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: Cookie: HTTPSBIZAPPHK=!/hIHetE6OOSfoqLMeF0cQdf86OMezNaG8DYEhDP9HmUdjbqRk1TFf/8qqyS8oQ/TXZbRS8XQvkfIgQ==; TS019e0bf9=018de30b9afd7d6b7907b55052d4bb828cd0eb5e457ef1ac86bda5de66a6dc0ee32ee35aed11af493778be36f9d0d42989051a2c5c; JSESSIONID=0000g3ZKZ6Vgj6W1acswtPybLjS:8f3c1488-34d6-4617-a01c-3939d9edb88f; HSBCHASEpersisted=_1_c54fe076c2ae4c57b4a341fe0520ec10_1648115941241_1397606692_1648196272829_5
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: User-Agent: okhttp/4.9.2
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: ADRUM_1: isMobile:true
  2022-03-25 16:17:58.483 I/okhttp.OkHttpClient: ADRUM: isAjax:true
  
  2022-03-25 16:17:58.513 I/okhttp.OkHttpClient: --&gt; END POST (4647082-byte body)
  2022-03-25 16:18:22.888 I/okhttp.OkHttpClient: &lt;-- 200 OK https://www.xxxxx.com/xxxx/xxxx/xxx/AAA (24375ms)
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Date: Fri, 25 Mar 2022 08:18:11 GMT
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: X-Frame-Options: SAMEORIGIN
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Strict-Transport-Security: max-age=16070400; includeSubDomains
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: ADRUM_0: clientRequestGUID:f5a3d565-ba1a-4655-996e-85041b816d89
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: ADRUM_1: globalAccountName:IAMGROOT_5c759262-dd33-4e7b-83aa-ce9e068cd960
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: ADRUM_2: btId:1524095
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: ADRUM_3: btERT:122
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: ADRUM_4: serverSnapshotType:p
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Expires: Thu, 01 Jan 1970 00:00:00 GMT
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: X-XSS-Protection: 1; mode=block
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: X-Frame-Options: sameorigin
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: X-Content-Type-Options: nosniff
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Content-Length: 50
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Content-Type: application/json; charset=UTF-8
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Content-Language: en-GB
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: S: LGBB01CPHS-WS
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Keep-Alive: timeout=5, max=100
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: Connection: Keep-Alive
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: {&quot;responseCode&quot;:&quot;3001&quot;,&quot;message&quot;:&quot;pending result&quot;}
  2022-03-25 16:18:22.889 I/okhttp.OkHttpClient: &lt;-- END HTTP (50-byte body)
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: --&gt; POST https://www.xxxxx.com/xxxx/xxxx/xxx/BBB http/1.1
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: Cache-Control: no-cache
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: Content-Type: application/json; charset=UTF-8
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: Content-Length: 24
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: Host: www.xxxxx.com
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: Connection: Keep-Alive
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: Accept-Encoding: gzip
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: Cookie: HTTPSBIZAPPHK=!/hIHetE6OOSfoqLMeF0cQdf86OMezNaG8DYEhDP9HmUdjbqRk1TFf/8qqyS8oQ/TXZbRS8XQvkfIgQ==; TS019e0bf9=018de30b9afd7d6b7907b55052d4bb828cd0eb5e457ef1ac86bda5de66a6dc0ee32ee35aed11af493778be36f9d0d42989051a2c5c; JSESSIONID=0000g3ZKZ6Vgj6W1acswtPybLjS:8f3c1488-34d6-4617-a01c-3939d9edb88f; HSBCHASEpersisted=_1_c54fe076c2ae4c57b4a341fe0520ec10_1648115941241_1397606692_1648196276403_5
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: User-Agent: okhttp/4.9.2
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: ADRUM_1: isMobile:true
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: ADRUM: isAjax:true
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: {&quot;requestID&quot;:&quot;A7L2T1JG&quot;}
  2022-03-25 16:18:28.895 I/okhttp.OkHttpClient: --&gt; END POST (24-byte body)
  2022-03-25 16:18:28.896 I/okhttp.OkHttpClient: &lt;-- HTTP FAILED: java.io.IOException: unexpected end of stream on https://www.xxxxx.com/...
  </code></pre>
  <p>Anyone has idea about this? What code from OKHttp caused this problem? Is the header for close connection a perfect solution? Appreciate for any idea! Thank you</p>