Android Question http request to jsp service

barry davis

Member
Licensed User
Longtime User
with code directly from the forums, the response comes back over 30 seconds after the httpjob request. A couple of notes:
1. response in under a second using b4j, same response using ios/swift
2. response in under a second using b4a webview, same response using firefox browser on PC or mac

the test code (from the sample on the forum) is below:

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Test2Layout")

'WebView1.LoadUrl ("http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp")

Dim j As HttpJob
j.Initialize("j", Me)
j.Download("http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp")

End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)
End Sub

Sub JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
Else
Log(j.ErrorMessage)
End If
j.Release
End Sub


Any suggestions would be helpful, as this seems unusual

Thanks in advance,
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please use [code]code here...[/code] tags when posting code.

Tested with this code (OkHttpUtils2):
B4X:
Sub Process_Globals
   Private start As Long
End Sub

Sub Globals

End Sub

Sub Activity_Create(FirstTime As Boolean)
   Dim job1 As HttpJob
   job1.Initialize("Job1", Me)
   start = DateTime.Now
   job1.Download("http://www.fly.faa.gov/flyfaa/xmlAirportStatus.jsp")
   
End Sub

Sub JobDone (Job As HttpJob)
   Log($"Took: $1.2{(DateTime.Now - start)/DateTime.TicksPerSecond} seconds"$)
   If Job.Success = True Then
     Log($"Result: ${Job.GetString}"$)
   Else
     Log("Error: " & Job.ErrorMessage)
   End If
   Job.Release
End Sub

Takes less than one second.
 
Upvote 0

barry davis

Member
Licensed User
Longtime User
Erel,

Thank you for getting back so quick. I replaced original test code with the code you provided.

The result was a timeout with the following message:

** Service (starter) Create **
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
** Service (httputils2service) Create **
** Service (httputils2service) Start **
Took: 30.32 seconds
Error: java.net.SocketTimeoutException: failed to connect to www.fly.faa.gov/2600:1408:1d:29a::21f5 (port 80) after 30000ms

I also tried the code on a different device (both samsung) and got the same result.

Using httputil2 the response came back in 60 seconds. The response above came from okhttputil2. It seemed very interesting that there are different results. It is also interesting that the URL in the error message is different that wihe request.

I have other calls in the app that that worked fine. i changed the url in the test code and the response took .48 seconds.

That leaves me with the question on why the URL changed, and does that help to understand the issue.

Thanks in advance,
barry
 
Upvote 0
Top