Android Question OkhttpUtils2 timeout

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi,
How to set the timeout when using OkHttpUtils2 lib?
I serach the forum and try

Dim HttpJob1 As HttpJob
HttpJob1.download(URL)
HttpJob1.GetRequest..... but theres no timeout

Thanks
 

DonManfred

Expert
Licensed User
Longtime User
If i remember correctly you need to add okhttp lib TOO for this
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
No way, using download or download2 theres no getrequest.timeout, see image
 

Attachments

  • 2017-02-10_2052.png
    2017-02-10_2052.png
    4.4 KB · Views: 239
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
OK, thanks, I did it and set the timeout to:
httpPayment.GetRequest.Timeout = 5000 (5 secs)
but when reading it is still in 30 secs
Any idea?
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
but the timeout does not change

How do you measure it?

My call which works:

B4X:
Dim GetItemsJob As HttpJob
    GetItemsJob.Initialize("GetItems", Me)
    GetItemsJob.PostString(ServerAddress & "/xxxx/xxxxx.php", JSONstring)
    GetItemsJob.GetRequest.Timeout=3000 '3 secs
 
Upvote 0

Marc De Loose

Member
Licensed User
Longtime User
Im running into somewhat of the same problem.
It somehow goes back to the 30 second default.

I can easely test it.

I unplug the internet connection from my router.
I activate the service. It works
I keep trying and after a while it is again timing out in 30 seconds.

Plug it back in
And it goes back to the timeout I set.

Any ideas?

(I am running httpjob in a service that checks for an intent to fire some homeautomation stuff.)
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
There are 2 scenarious:

1. The ip address is not available (= server does not respond)
2. The internet connection is not avilable (= unplug the router)

I assume only the timeout for the request ittself (#1) can be changed, not for the internet connection (maybe android waits 30 secs for the connection to be available)
 
Upvote 0
Top