HttpUtils2 and java.net.SocketTimeoutException

basil99

Active Member
Licensed User
Longtime User
Hi!

My app i'm develope atm, is based on HttpUtils2 and works as expected, but there is one thing i need to fix. I mean java.net.SocketTimeoutException that happens from time to time especially if connection is unstable or server slow.

Is any way to handle it ? Like fire an event then contain a HttpJobName ( i download several files ) ? Also, what i need to do in these case - resubmit HttpJob ?

Thanks
 

Shay

Well-Known Member
Licensed User
Longtime User
I am getting error that Timeout is not valid, why?
job2.GetRequest.Timeout = 60000 '60 seconds
 
Upvote 0

Shay

Well-Known Member
Licensed User
Longtime User
I did, and now I have it, but not sure it did what I need it to do:
I need that if for example I try to download some file via server with:
Job2.Download
if not getting response from server within the "timeout" it will release the job (skip it)
 
Upvote 0

Dieter Baumgartner

Member
Licensed User
Longtime User
Timeout to 60000 doesn't change anything. Still getting java.net.SockettimeoutException from time to time. It looks like this is a protocol problem between Router & Smartphones. It is not always, but often when downloading big files > 10 MB with HttpJob and Httputils2.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
I have the same issue as well ( timeout on HTTP calls, no large files just simple calls to a web service ). I have tried several different tablets,phones and even service providers. To confirm that the issue wasn't server related, I had 4 devices tested at the same time. Randomly some of them will get an error while others are working ok. Then they start to work ( no specific pattern )
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Honestly I tried everything on earth. I have been struggling with this issue for a long time. Things that are worth mentioning:
1. Changing Time out values didn't change anything
2. When the call fails ( or during failure ), browsing the internet from the tablet is no issue
3. When the call fails ( or during failure ), web service is responding other requests from other sources
4. The issue is tablet independent ( the same tablet will work while the other one is not and vice versa )
5. Tried different tablet models and different phones
6. Tried several service providers at the same time, still got the same issue
7. Tried over WiFi and Mobile Networks. Same results
8. calls that I am using are simple HTTP calls nothing fancy ( no file downloads )

Currently I am using some retry mechanism to fix the issue, however it is not perfect. ( it does the job in several cases ), but a delay of a minute ( meaning waiting for a time out to occur ) for a request feels like a year for the end user.


This line below is not 100% sure, I am still trying to duplicate the issue ( but may be will give you some idea )
I have also noticed that in some cases the requests ( including my retries ) all of a sudden appear at the server, all at the same time ( even after the time out occurs on the tablet )

Your help would be greatly appreciatad
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
I'm using httputils with php. No problems so far. Are you able to create a simple php script to log some data? I would send a timestamp and log it with a timestamp the script runs.

And... Are you really sure it's not a server related issue? Did you take a look to the server logs?

Are you the only person who accesses the server? If no: How many users are using your app?
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
currently the app still in testing stage. I am the only user on the app. which simplifies the debugging process.
Here is what we will do in the next couple of days
We will implement a little utility that will run on a PC and will issue HTTP calls to the exact same server and will log time sent, time response received and if any failure occurred. I think that should be a fair test.
If you see any issues with the above, please let me know
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
Some questions:

What kind of server is it? Hosted or did you set it up on your own?
Which script is called? PHP? (or are you just using a link to download a file?)
If you just downloading using a link, change the link for a test to a public server (see examples here for downloading images).

Last week we had one pc with ping times >3secs and packet losses. Reason was a change in my sons room and the connection was weak. Fixed it. Maybe something like this?
 
Upvote 0

pmg

Member
Licensed User
Longtime User
I have a similar problem.
This is the relevant code which is run in a loop:

Dim job1 As HttpJob
job1.Initialize("Job1", Me)
Try
job1.Download(url)
Catch
Msgbox(LastException.Message,"TRYCATCH")
End Try

I start the app with Wifi enabled, and the program works.
Then I disable Wifi.
I get a message in a black box (Not the MsgBox) which says

Error: java.net.UnknownHostException
Unable to resolve host
No address associated with hostname

This is clearly the type of error that I would expect but it is not being trapped by the main thread.

As I understand it, httpUtils2 runs the request in the background somehow, so it shouldn't be a surprise that
when resolving fails it isn't trapped by the main thread.

Somewhere in httpUtils2 there is some code that needs wrapping in a try/catch block.

Is there any chance of a fix to this library?
 
Upvote 0

b4xscripter

Member
Licensed User
Longtime User
Hello,
I have a similar issue.

I use:

Sub lbl_send_Location_Click

p.HideKeyboard(Activity)
Dim job As HttpJob
job.Initialize("gps", Me)
job.PostString(cleaningService.serverLink & "/gps", "lat=" & cleaningService.client_latitude & "&lon=" & cleaningService.client_longitude & "&clientId=" & cleaningService.clientId )

End Sub



This request is perfectly delivered to my server (express.js), processed with no errors. But in a lot of time in the code Sub JobDone (Job As HttpJob) I get this error:

java.net.SocketTimeoutException

I insist that this request arrives perfectly to my server and executed with no errors.

I think that the problem should be the time that the job takes to be executed. Indeed, when I change my /gps service for the faked one, I don't have this error. But my service on the server side only takes 1-2 seconds!!!!!

Best regards
 
Upvote 0
Top