Hi Erel,
HttpJob should never be a global variable.
I have declared HttpJob inside the function but the timeout still sticked to 20 seconds
[CODE lang="b4x" title="httpjob inside a function" highlight="httpjob inside a function"]Sub Button1_Click
Log("+++ Start: " & DateTime.Time(DateTime.Now))
' timer.Enabled = True
Dim j As HttpJob
j.Initialize("", Me)
j.Download("https://www.google.com")
j.GetRequest.Timeout = REQUEST_LIMIT * DateTime.TicksPerSecond
'LogColor("TicksPerSecond: " & DateTime.TicksPerSecond, Colors.Blue)
LogColor("Request limit: " & (REQUEST_LIMIT * DateTime.TicksPerSecond), Colors.Blue)
ProgressDialogShow2("querying...", True)
Wait For (j) JobDone(Job As HttpJob)
Dim isJobSuccess As Boolean = Job.Success
j.Release
If isJobSuccess = False Then
LogColor("Connetion Error: " & CRLF & Job.ErrorMessage, Colors.Red)
End If
Log("is Success? " & isJobSuccess)
ProgressDialogHide
Dim lng2 As Long = DateTime.Now
Log("=== End (JobDone): " & DateTime.Time(lng2))
If timer.Enabled Then
timer.Enabled = False
End If
End Sub[/CODE]
[CODE title="log" highlight="log"]*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **
** Activity (testtimeout) Create, isFirst = true **
Timer limit: 5000
** Activity (testtimeout) Resume **
+++ Start: 10:04:09
Request limit: 2000
*** Service (httputils2service) Create ***
** Service (httputils2service) Start **
ResponseError. Reason: java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname, Response:
Connetion Error:
java.net.UnknownHostException: Unable to resolve host "www.google.com": No address associated with hostname
is Success? false
=== End (JobDone): 10:04:29
** Activity (testtimeout) Pause, UserClosed = false **
[/CODE]
I think the Request's timeout of HttpJob is not working.
The error has nothing to do with the timeout. It looks like the device isn't connected to the internet.
I intended to set the WiFi of mobile phone to a hotspot which has already disconnected to internet because I want to see what happen when the mobile is disconnected to internet.