Android Question org.apache.http.conn.ConnectTimeoutException

danijel

Active Member
Licensed User
Hi
I am trying to download Html page using Httpjob.
Everything works fine on my 4 test devices except on Htc Desire 601 (KitKat)

Only on that device sometimes (1 in 10 times approx.) I get this error:
org.apache.http.conn.ConnectTimeoutException: Connect to /xxx.xxx.xxx.xxx:80 timed out

P.S. That device is on the same Wi-Fi as my other 4 devices.
Wi-Fi is working all the time. And Internet works on all devices all the time

What's causes this error?
-My device,
-My code or
-My remote server

...and how to fix this? o_O

Thank you in advance
 

danijel

Active Member
Licensed User
I am using httpjob only once.
router works fine for other devices and for that device in 90% cases.

hmm o_O
 

MarcoRome

Expert
Licensed User
Hi
I am trying to download Html page using Httpjob.
Everything works fine on my 4 test devices except on Htc Desire 601 (KitKat)

Only on that device sometimes (1 in 10 times approx.) I get this error:
org.apache.http.conn.ConnectTimeoutException: Connect to /xxx.xxx.xxx.xxx:80 timed out

P.S. That device is on the same Wi-Fi as my other 4 devices.
Wi-Fi is working all the time. And Internet works on all devices all the time

What's causes this error?
-My device,
-My code or
-My remote server

...and how to fix this? o_O

Thank you in advance
Something
if you have two or more devices on the same Wi-Fi network and try to connect on MySql ... you have this error.
Try to connect a device over wi-fi and the other Internet phone and you'll see that you will not have this error.
I didn't understand why.
Any idea ??
 

danijel

Active Member
Licensed User
Yes, I noticed that too.
On 3G works fine,
but sometimes there is an error if more devices is on same Wi-Fi
 

MarcoRome

Expert
Licensed User
Yes, I noticed that too.
On 3G works fine,
but sometimes there is an error if more devices is on same Wi-Fi
Yes agree somethings for me.
I have 2 device in Wi-Fi and i have this error.
If run one device in internet mobile ( 1 device in wi-fi / 1 device in inet mobile ) all work without problem.
So seem that 2 o more device that work in some Wi-Fi have this error
 

MarcoRome

Expert
Licensed User
Hi all.
I have this simple code:
B4X:
Sub Process_Globals
 
    'These global variables will be declared once when the application starts.
       'These variables can be accessed from all modules.
    Dim httpC As HttpClient
    Dim httpD As HttpClient
 
    Dim GENERE = "genere" As String
    ' Inserire Pw e Server e compilare come obfuscated
    Dim ipserver, dbname, dbpw, userdb As String
    'richiamo DB MySQL
    ipserver = "xxx.xx.xxx.xxx"
    dbname = "xxxx"
    dbpw = "xxxxx"
    userdb = "xxxx"
   
End Sub
 
Sub Globals
    Private ListView1 As ListView
End Sub
 
Sub Activity_Create(FirstTime As Boolean)         
                Activity.LoadLayout(dispositivo)
                ExecuteRemoteQuery("SELECT a, b FROM example", GENERE)
End Sub
 
 
Sub ExecuteRemoteQuery(Query As String, JobName As String)
    Dim job As HttpJob
    job.Initialize(JobName, Me)
    job.PostString("http://www.xxxxx.eu/db.php?hst="&ipserver&"&db="&dbname&"&usr="&userdb&"&pwd="&dbpw&"", Query)
End Sub
 
 
 
Sub JobDone(Job As HttpJob)
    ProgressDialogHide
    If Job.Success Then
    Dim res As String
        res = Job.GetString
        Log("Response from server: " & res)
        Dim parser As JSONParser
        parser.Initialize(res)
        Select Job.JobName
 
        'Seleziono Esempio
        Case GENERE
                Dim COUNTRIES As List
                Dim m As Map
                m.Initialize
                COUNTRIES = parser.NextArray 'returns a list with maps
                For i = 0 To COUNTRIES.Size - 1
                    m = COUNTRIES.Get(i)
                    ListView1.AddTwoLines(m.Get("a"), m.Get("b"))
                Next
        End Select
    Else
        ToastMessageShow("Error: " & Job.ErrorMessage & " Errore connessione Internet, verificare!!", True)
    End If
    Job.Release
End Sub
Everything works if:
A) using a single device on the same wi-fi
B) use multiple devices on different inet (such as a mobile device on inet + 1 device on wi-fi)

If i try with two devices on the same wi-fi, the first run the code, the second remains on standby, after giving me a few seconds this error:
org.apache.http.conn.ConnectTimeoutException: Connect to /xxx.xxx.xxx.xxx:80 timed out

Any ideas?

thank you
Marco
 

MarcoRome

Expert
Licensed User
I have a doubt , while using Job.release , in theory should release resources ( but connection is anyway open ) the service work anyway. If after job.relese add
StopService(HttpUtils2Service)

B4X:
Job.Release
StopService(HttpUtils2Service)
Contraindications ??
 

MarcoRome

Expert
Licensed User
Hi
I am trying to download Html page using Httpjob.
Everything works fine on my 4 test devices except on Htc Desire 601 (KitKat)

Only on that device sometimes (1 in 10 times approx.) I get this error:
org.apache.http.conn.ConnectTimeoutException: Connect to /xxx.xxx.xxx.xxx:80 timed out

P.S. That device is on the same Wi-Fi as my other 4 devices.
Wi-Fi is working all the time. And Internet works on all devices all the time

What's causes this error?
-My device,
-My code or
-My remote server

...and how to fix this? o_O

Thank you in advance
RESOLVED.
You can
1. Use RDC
2. Use Library MySql DonManfred ... already Tested and work without problem.
 
Top