I try to get json from a server, I use https on the server and every http request will go to the https version.
I get the data and the data that I send works to but it takes up to 45 sec to get a response back. The same code was faster with the build in http handler of android.
How can I speed up the request?
try {
OkHttpClient client = new OkHttpClient();
FormBody.Builder formBuilder = new FormBody.Builder().add("key", "2285");
//formBuilder.add("phone", "000000");
RequestBody formBody = formBuilder.build();
Log.v("JsonRespons", reqUrl);
Request request = new Request.Builder()
.url(reqUrl)
.post(formBody)
.build();
okhttp3.Response response = null;
response = client.newCall(request).execute();
if (!response.isSuccessful()) {
throw new IOException(response.message() + " " + response.toString());
} else {
output = response.body().string();
}
if(output != null) {
Log.v("JsonRespons", output.toString());
}
} catch (IOException e) {
e.printStackTrace();
}