title: How to increase the timeout of a request in OkHttp in android?
body: <p>I am trying to make an app which will connect to a flask server. I am using the OkHttp library for sending and receiving data. My problem is I want to run a python script which will take at least 2 mins to complete and then send a &quot;success&quot; message after completion on a button click. So whenever I send a request to the server, I always get a timeout message in my android logcat. So I would like to know if there is any method to increase the timeout.</p>
  <p>Here is my onResponse function:</p>
  <pre><code>public void onResponse(Call call, final Response response) throws IOException {
  
              runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                      try {
                          String loginResponseString = response.body().string().trim();
                          Log.d(&quot;LOGIN&quot;, &quot;Response from the server : &quot; + loginResponseString);
                          if (loginResponseString.equals(&quot;success&quot;)) {
                              Log.d(&quot;Artist&quot;, &quot;Artist Found&quot;);
                              
                          } else if (loginResponseString.equals(&quot;failure&quot;)) {
                              Log.d(&quot;Artist&quot;, &quot;Artist Not Found&quot;);
                          }
                      } catch (Exception e) {
                          e.printStackTrace();
                          Toast.makeText(Artist.this, &quot;Something went wrong. Please try again later.&quot;, Toast.LENGTH_SHORT).show();
                      }
                  }
              });
  </code></pre>
  <p>Whenever I give a request, the code always executes the catch part.</p>
  <p>Android Logcat:</p>
  <pre><code>D/FAIL: timeout
  </code></pre>
  <p>PS. I'm a beginner and I don't know much about flask and android development</p>