0

I have a small trouble with okhttp.

  1. How to set a connect time (for ex. 10 sec and this 10 sec okhttp lib should try to get a response from server)?

  2. How to set a connect tries (for ex. when this 10 sec is ended)?

Pang
  • 9,073
  • 146
  • 84
  • 117

1 Answers1

0
        client = new OkHttpClient();
        client.setConnectTimeout(10, TimeUnit.SECONDS);
        client.setReadTimeout(10, TimeUnit.SECONDS);
        client.setWriteTimeout(10, TimeUnit.SECONDS);