1

I have one api that retrives a huge data , I set the timeout to 7 min no more than that. So when the waiting time exceeds 7 min I want the operation to be cancelled

However , the users sometimes wait till 10 min and more ..

Below is the code

   final OkHttpClient okHttpClient = new OkHttpClient.Builder()
            .connectTimeout(connectTimeOut, TimeUnit.SECONDS)
            .readTimeout(readTimeOut, TimeUnit.SECONDS)
            .build();

What I'm missing here?

Rahul
  • 81
  • 2
  • 7

1 Answers1

0

Connection timeOut is the time to establish a connection and read/writeTimeout is the time required to read or write after establishing connection. so finally

totalTimeout = connectTimeOut + readTimeout

Your httpClient taking extra time in connectionEstablishment or readTimOut. You have to configure this two timeout in a way that user need not to wait more than your defined time. Please accept my answer if is satisfactory

Note: All the operation takes less or equal time you defined to complete.

For your better understanding visit this link Http Client Time Out Guide

Rezaul Karim
  • 830
  • 8
  • 15
  • 1
    So in the code snippet the value of connection timeout is 7 min and read timeout is 7 min so total is 14 min but some users wait to 30 min , How is that possible? – Rahul Jan 28 '21 at 09:13