Hi I am consuming a REST Web Service using an HttpJob and setting the TimeOut to 6 seconds with this command XJob.GetRequest.Timeout = 6000, this timeout is very important, because it is a heavy duty App and if the WebService takes more than 6 seconds, I need to continue with another process .
But I have been told that this Timeout is only for Connection and that OkHttp has timeout for Connection and Read (https://www.baeldung.com/okhttp-timeouts). So when the connection lasts more than 6 seconds, the connection timeout is triggered and everything works fine.
The problem comes when the connection lasts less than 6 seconds, but the WebService response lasts up to 30 seconds, that timeout is controlled by the readTimeout. I found this code in Java, but I don't know Java and how to implement it in B4A:
Is there any way to set the readTimeout from B4A?
I would appreciate any help because I am over my deadline and my client is starting to get upset.
Thanks in advance.
But I have been told that this Timeout is only for Connection and that OkHttp has timeout for Connection and Read (https://www.baeldung.com/okhttp-timeouts). So when the connection lasts more than 6 seconds, the connection timeout is triggered and everything works fine.
The problem comes when the connection lasts less than 6 seconds, but the WebService response lasts up to 30 seconds, that timeout is controlled by the readTimeout. I found this code in Java, but I don't know Java and how to implement it in B4A:
B4X:
@Test
public void whenReadTimeoutExceeded_thenSocketTimeoutException() {
OkHttpClient client = new OkHttpClient.Builder()
.readTimeout(10, TimeUnit.MILLISECONDS)
.build();
Request request = new Request.Builder()
.url("https://httpbin.org/delay/2") // 2-second response time
.build();
Throwable thrown = catchThrowable(() -> client.newCall(request).execute());
assertThat(thrown).isInstanceOf(SocketTimeoutException.class);
}
Is there any way to set the readTimeout from B4A?
I would appreciate any help because I am over my deadline and my client is starting to get upset.
Thanks in advance.