We would like some clarification on the use of relative timeouts used in OkHttp.
The client has the following 4 settable timeouts:
a. connectTimeout (default 10 seconds)
b. writeTimeout (default 10 seconds)
c. readTimeout (default 10 seconds)
d. callTimeout
From the B4a documentation, set timeouts only on the http request object.
The Okhttp library B4a wrapper sets the following timeouts
connectTimeout, writeTimeout, readTimeout defaults to 30 seconds.
We are creating an Android app, which must send data in POST to REST web services and the size of the data to be sent in a single request can be considerable, being on it can even exceed 2MB for each request.
We are using the latest version of the B4a library "okhttp-4.9.0.jar", and reading the http client configuration parameters it results in a 30 second timeout, but the client raises the timeout after 10 seconds.
From this message
www.b4x.com
you can view the code to customize the required timeouts, but using it the compiler reports the following error:
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, is First = true **
Cannot get methods of class: okhttp3.OkHttpClient$Builder, disabling cache.
Error occurred online: 81 (HTTPClient)
java.lang.RuntimeException: Method: connectTimeout not found in: okhttp3.OkHttpClient$Builder
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
for example.http.client.httpclient._settimeout(httpclient.java:102)
at example.http.client.main._activity_create(main.java:405)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at example.http.client.main.afterFirstLayout(main.java:105)
at example.http.client.main.access$000(main.java:17)
at example.http.client.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:735)
How can we set the timeouts in the subject of this message?
Thank you.
The client has the following 4 settable timeouts:
a. connectTimeout (default 10 seconds)
b. writeTimeout (default 10 seconds)
c. readTimeout (default 10 seconds)
d. callTimeout
From the B4a documentation, set timeouts only on the http request object.
The Okhttp library B4a wrapper sets the following timeouts
connectTimeout, writeTimeout, readTimeout defaults to 30 seconds.
We are creating an Android app, which must send data in POST to REST web services and the size of the data to be sent in a single request can be considerable, being on it can even exceed 2MB for each request.
We are using the latest version of the B4a library "okhttp-4.9.0.jar", and reading the http client configuration parameters it results in a 30 second timeout, but the client raises the timeout after 10 seconds.
From this message
How to set readTimeout in a OkHttp connection
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 ...
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, is First = true **
Cannot get methods of class: okhttp3.OkHttpClient$Builder, disabling cache.
Error occurred online: 81 (HTTPClient)
java.lang.RuntimeException: Method: connectTimeout not found in: okhttp3.OkHttpClient$Builder
at anywheresoftware.b4j.object.JavaObject$MethodCache.getMethod(JavaObject.java:363)
at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:120)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:262)
for example.http.client.httpclient._settimeout(httpclient.java:102)
at example.http.client.main._activity_create(main.java:405)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:146)
at example.http.client.main.afterFirstLayout(main.java:105)
at example.http.client.main.access$000(main.java:17)
at example.http.client.main$WaitForLayout.run(main.java:83)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5258)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:940)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:735)
How can we set the timeouts in the subject of this message?
Thank you.