title: Okhttp3+android has a significant delay between responseHeadersStart and responseHeadersEnd
body: <p>I am using okhttp 4.0.1 in an Android app and there is a significant delay when receiving the response, particularly the headers. This adds a significant delay time to the users (ranging around 2-5 seconds) per request sent. The time delay is measured using okhttp's EventListenerfrom here <a href="https://square.github.io/okhttp/events/" rel="nofollow noreferrer">https://square.github.io/okhttp/events/</a></p>
  
  <p>This code is already placed inside an AsyncTask. Note that the delay happens after <code>mCall?.execute</code></p>
  
  <pre><code>        val mBuilder = Request.Builder()  
          val url = ....
          // Add URL
          mBuilder.url(url) // Request.Builder
  
          // Request
          val req = mBuilder.build()
  
          // Call
          var resp: Response? = null
          var code = RESPSTATUS_IOEXC
          var body = ""
          try {
              // Execute the call
              mCall = mClient.newCall(req)
              resp = mCall?.execute()
              code = resp?.code?: 0
              body = resp?.body?.string()?: ""
          } catch (e: ConnectException) {
              e.printStackTrace()
              code = RESPSTATUS_CONNECTION_FAILED
          } catch (e: SocketTimeoutException) {
              e.printStackTrace()
              code = RESPSTATUS_TIMEOUT
          } catch (e: IOException) {
              e.printStackTrace()
              code = RESPSTATUS_IOEXC
          } catch (e: IllegalStateException) {
              e.printStackTrace()
              code = RESPSTATUS_ALREADY_EXEC
          } catch (e: CertificateException) {
              e.printStackTrace()
              code = RESPSTATUS_INVALID_CERT
          } finally {
              resp?.close()
          }
  </code></pre>
  
  <p>One of the example messages showing the delay (3s delay retrieving response headers):</p>
  
  <pre><code>[1] dns started!
  [1] dns ended!
  [1] connect started!
  [29] secure connect started!
  [46] secure connect ended!
  [46] connect ended!
  [46] connection acquired!
  [46] request headers started!
  [47] request headers ended!
  [47] response headers started!
  [3676] response headers ended!
  [3676] response body started!
  [3702] response body ended!
  [3704] connection released!
  [3704] call ended!
  </code></pre>
  
  <p>Sample of the response headers I am getting</p>
  
  <pre><code>------ header(Server): nginx/1.10.3 (Ubuntu)
  ------ header(Date): Thu, 08 Aug 2019 15:08:02 GMT
  ------ header(Content-Type): application/json
  ------ header(Content-Length): 33071
  ------ header(Connection): close
  ------ header(Vary): Content-Type
  ------ header(Strict-Transport-Security): max-age=15552000; includeSubDomains; preload;
  </code></pre>
  
  <p>Our iOS team has called the URLs given without any considerable delay (1-2s max), so I do not know if the problem lies in the code or the server itself.</p>
  
  <p>Any help is appreciated. Thanks before</p>