Android Question HttpUtils2 poststring timeout

AlteregoHR

Member
Licensed User
Longtime User
Hello,
I call job.poststring("http...") to detect if server is online and if it is then I call another job to get the data. Problem is that if user start application and the server is down first job which checks if server is available takes some time to timeout. If in that time user starts another activity when timeout occures that activity gets closed and activity which started http request gets focus. How do I prevent this? And how do I set poststring timeout duration?
Thanx
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
Dim httpPayment As HttpJob
httpPayment.Initialize("httpPayment", Me)
httpPayment.Download2("https://abc.com/xyz.asp",aString)
httpPayment.GetRequest.Timeout = 60000

Note that the GetRequest.Timeout comes AFTER .download2()
In your case after

B4X:
job.poststring("http...")
job.GetRequest.Timeout = 60000
 
Upvote 0

AlteregoHR

Member
Licensed User
Longtime User
Thank you. Will try shorter timeout to prevent user from going to fast to another activity. What do you think that is shortest timeout that still get server time to respond?
 
Upvote 0

fbritop

Active Member
Licensed User
Longtime User
Erel
I'm trying to setup the timeout, but when I compile it throws the following error:

Parsing code. 0.10
Compiling code. Error
Error compiling program.
Error description: Unknown type: anywheresoftware.b4a.http.HttpClientWrapper.HttpUriRequestWrapper
Are you missing a library reference?
Occurred on line: 341
jobLogin.GetRequest.Timeout =5000
Word: timeout

Using B4A version 3.82, the httpUtils2 library is checked at the IDE (version 2.01)

Do I have to put the Timeout directly from the jobLogin object?

Thanks
Felipe Brito
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
Erel
I'm trying to setup the timeout, but when I compile it throws the following error:

Parsing code. 0.10
Compiling code. Error
Error compiling program.
Error description: Unknown type: anywheresoftware.b4a.http.HttpClientWrapper.HttpUriRequestWrapper
Are you missing a library reference?
Occurred on line: 341
jobLogin.GetRequest.Timeout =5000
Word: timeout

Using B4A version 3.82, the httpUtils2 library is checked at the IDE (version 2.01)

Do I have to put the Timeout directly from the jobLogin object?

Thanks
Felipe Brito

Check HTTP too
 
Upvote 0

landrea2004

Member
Licensed User
Longtime User
Hello, I'm new of this forum. I have the same problem but i don't undestand how resolve.
Ask you help please ....???

Many Thanks
Andrew
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
Hello, I'm new of this forum. I have the same problem but i don't undestand how resolve.
Ask you help please ....???

Many Thanks
Andrew
what problem?
 
Upvote 0

landrea2004

Member
Licensed User
Longtime User
Thank Douglas for response,
I use this

Dim job1 As HttpJob
job1.Initialize("Als016AggArchTabArt",Me)
job1.PostString("http://ServerName/Script.aspx","")
job1.GetRequest.Timeout = 60000

but when compile get Error in line with Timeout istruction.
The Lib HttpUtil2 is Version 2.01

Launch the script on the server that takes 3 minutes
and the program give me JobSuccess = false before the end of the script on the server.
Reading in the forum I found that you were talking
about putting the timeout and so I tried it but it gives me the error

How i can resolve ?

Thanks.
Andrew
 
Upvote 0

Douglas Farias

Expert
Licensed User
Longtime User
u need check the lib HTTP on the right of ide >>>> on tab Lib
look this image i made
 

Attachments

  • Sem título.png
    Sem título.png
    183.1 KB · Views: 540
Upvote 0
Top