Android Question Mysql php connection timeout

taylorw

Active Member
Licensed User
Hi all, i using php to get data from my server mysql database.

Code like below.
B4X:
Sub ExecuteRemoteQuery(Query As String, JobName As String)
   
    Dim job As HttpJob
    job.Initialize(JobName, Me)
    job.PostString("http://www.XXX.com/countries.php", Query)
   
End Sub

But my question is how to change the timeout limit, because i reading some bigger data but over 30+/-sec
it have error like that.
B4X:
ResponseError. Reason: java.net.SocketTimeoutException, Response:
java.net.SocketTimeoutException
 

DonManfred

Expert
Licensed User
Longtime User
Search the forum how to change the timeout for a httpjob. I´m sure you´ll find the answer
 
Upvote 0

yge

Member
Licensed User
In case you didn't manage to find what you need, this is the answer:

Make sure you have OkHttp library enabled. Add this row at the end:

B4X:
job.GetRequest.Timeout = 60000

You can adjust the value (60000 = 60 seconds)
 
Upvote 0

KMatle

Expert
Licensed User
Longtime User
ResponseError. Reason: java.net.SocketTimeoutException, Response:
java.net.SocketTimeoutException

To be honest:

- If your request takes more than 0.5 secs there must be a design issue in your app
- If you want to download 10000 rows -> Dont' do that (except there is an acceptable reason which is not given in 99.99% of all cases)
- If you want do download MB's of data -> see #2

Good practice:

- if your request needs more than 0.5 (secs) there MUST be a design issue (bad db design, indexes wrong, etc)
- Only download what the USER can handle at one time (e.g. 50 rows max.)
- download more only if he/she REALLY NEEDS it
- if you need to download huge data use (s)ftp
- if it's a batch job (like to process 100.000 rows -> don't do that with an app, it's a server's job or B4J) -> even here: Only load 100 rows at one time!

My requests (millions of rows in a db) take about 0.05 secs MAX! so I always DECREASE the timeout to 2 secs (if something really goes wrong like bad internet connection)
 
Upvote 0
Top