Android Question Strange POST delay

udg

Expert
Licensed User
Longtime User
Hi all,
I'm experiencing a strange delay when executing a POST operation using standard code as below.
Why strange? Because exactly the same code (it's a B4xPages project) used from the B4J counterpart takes 2 seconds at most while the B4A version waits for about 30 seconds prior to give the success response.

What could it be? What would you investigate first?

B4X:
Dim pJob As HttpJob
pJob.Initialize("", Me)
pJob.PostBytes(AppGlobals.hurl&"/pop",buffer)
Wait For(pJob) JobDone(j As HttpJob)
 If j.Success Then
...
ps: buffer length is only 154 bytes, so the problem should be elsewhere
pps: tried both Http and Https hurls

Update:
I tried to insert the following line after the pjob.initialize and the delay shortened to 5 seconds. So it sound like a kind of timeout, but I can't see why it passes, since the server response looks ok (it's successful and it carries the expected data).
And the initial question remains: why the delay/timeout applies only to the Android version?
B4X:
pjob.GetRequest.Timeout = 5000
ps: shortening the timeout to 100ms everything still works ok. Taking it to <80ms raises the timeout error.
 

Hamied Abou Hulaikah

Well-Known Member
Licensed User
Longtime User
why the delay/timeout applies only to the Android version?
You should check if there is firewall-related apps in your android like antivirus, also check internet connection to desalinated url & is it firewall-ed?
 
Upvote 0

Quandalle

Member
Licensed User
You can use a REST client application on ANDROID (e.g. pocket Postman,...) to see if by passing the same request you also have a long delay
 
Upvote 0

Sandman

Expert
Licensed User
Longtime User
What about the receiving side? Can you log anything?
Agreed. To me it sounds like there's a timeout happening on the server when you're running the B4A code. Simply put, the connection is open for about 30 seconds.

One way to test it would be to instantly have /pop return "testing" and be done with it, like as the first line of code. Your app won't be happy by that response obviously, but that's not important. We're only doing it to see how long it takes to complete the call.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Thak you all.
I control the receiving end, so I can log whatever comes in and eventually compute the time it takes to prepare the response in order to compare what happens when the sending app is the B4A one rather than its B4J counterpart.
Even more easily, I could use an "hello" service that's already in place on the receiving end and see what happens.

Those tests will give us some more insight.

ps: since the firewall hit me so many times in the past (due to its "paranoic" settings) I will check that too...
 
Upvote 0
Top