Android Question OkHttpUtils2 and Timeout issue

sirjo66

Well-Known Member
Licensed User
Longtime User
Hi all,
I have a little problem with OkHttpUtils2 (version 2.61) with B4A version 7.80

this code execute a GET request, wait for answer and then it goes on, so it work well
B4X:
' "esame" Activity
Dim j As HttpJob
j.Initialize("", Me)
j.Download2("http://........", Array As String("id", "value1", "aut", "value2"))
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
    Log(j.GetString)
Else
    Log(j.ErrorMessage)
End If
j.Release

Activity.Finish  ' exit from this activity
StartActivity("scheda") ' and start new activity

but some time the server is down, so I don't want to wait for 30 seconds (default timeout) but I want to skip and go on.

So I want to setup timeout connection, I found this solution https://www.b4x.com/android/forum/threads/httputils2service-httpjob-timeout.23427/#post-136058 but if I try to insert j.GetRequest.Timeout = 1000 it tell me that Timeout don't exist on GetRequest

How can solve it ??

If I try this code
B4X:
' "esame" Activity
Dim j As HttpJob
j.Initialize("", Me)
j.Download2("http://........", Array As String("id", "value1", "aut", "value2"))
Sleep(0)
j.Release

Activity.Finish  ' exit from this activity
StartActivity("scheda") ' and start new activity
don't work, because at the end of this code it load "scheda" activity, but when then, when JobDone is call (but there isn't JobDone sub), OS reload "esame" activity and it start again

Thanks
Sergio
 

DonManfred

Expert
Licensed User
Longtime User
You DID added the okhttp-library? It is needed if you want to change the GetRequest
 
Upvote 0
Top