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 "success" 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.
Here is my onResponse function:
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("LOGIN", "Response from the server : " + loginResponseString);
if (loginResponseString.equals("success")) {
Log.d("Artist", "Artist Found");
} else if (loginResponseString.equals("failure")) {
Log.d("Artist", "Artist Not Found");
}
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(Artist.this, "Something went wrong. Please try again later.", Toast.LENGTH_SHORT).show();
}
}
});
Whenever I give a request, the code always executes the catch part.
Android Logcat:
D/FAIL: timeout
PS. I'm a beginner and I don't know much about flask and android development