Android Question Weird exception trown

jgbozza

Member
Licensed User
Longtime User
I had this strange exception trown by httputils2service at the line 70
B4X:
job.success = success

org.apache.http.conn.connecttimeoutexception

Does anyone have a clue of what this might be ?

Untitled-1.png
 

jgbozza

Member
Licensed User
Longtime User
The system is working for 3 months with no problems. It came all of a sudden. I realize that the server is trowing an error because there was a bug in the XML (a employee forgot to enter the data), but anyway it is not reaching the timeout I think.
I am only using the job.getstring to check if the random number sent by the tablet was read by the server in order to check if there was a succesful connection. On an error scenerio the getstring should be the error page and the tablet should understand that there wasn't a succesful connection and keep the register in its own database to try a later connection.
I set the httputils2 timeout to 30 seconds (codes below).

This is the Service that uses the http2utils, calling itself every 21 seconds in case there are still register in the ab_fail table

B4X:
Sub Service_Start (StartingIntent As Intent)
    Dim rs As Cursor
    rs = SQL1.ExecQuery("SELECT * FROM ab_fail")
    If rs.RowCount <= 0 Then 
    Log (rs.RowCount)
       Main.tem_ab_fail = False
          CancelScheduledService ("")
        StopService("")
    Else
          StartServiceAt("", DateTime.Now+21000, True)'POOLING
        Main.tem_ab_fail = True
        sub_1
    End If
    rs.Close
End Sub

sub1 is setting the job timeout to 15 seconds

B4X:
        random = Rnd(0,1000)
        Dim job As HttpJob  
        job.Initialize("job_ab_fail"&random, Me)
        job.PostString(Main.IP & "cb_fail.asp?",txt) '<--- txt is the xml I'm posting which happened to be bugged 3 days ago
        job.GetRequest.Timeout = 15000

...and the jobdone

B4X:
Sub JobDone (job As HttpJob)
    If job.JobName = "job_ab_fail"&random Then
        If job.Success = True Then
           Dim check, check_random As String
            check = job.GetString
            Log(job.GetString)
            check_random = random
            If check_random = check Then
            'Log(check)
                SQL1.BeginTransaction
                    Try
                        For i = 0 To cont - 1
                            SQL1.ExecNonQuery("DELETE FROM ab_fail WHERE cod = '" & index(i) & "'")
                            'Log(index(i))
                        Next
                        SQL1.TransactionSuccessful
                    Catch
                        ToastMessageShow(LastException.Message, True)
                        'Log(LastException.Message)
                    End Try
                SQL1.EndTransaction               
            Else
                Main.tem_ab_fail = True
            End If
        Else
            Main.server_ok = False
            Main.tem_ab_fail = True
        End If
        job.release
    End If
End Sub

...and I changed the timeout of httputils2 this way

B4X:
Public Sub SubmitJob(job As HttpJob) As Int
    job.GetRequest.Timeout=30000
    taskCounter = taskCounter + 1
    TaskIdToJob.Put(taskCounter, job)
    If job.Username <> "" AND job.Password <> "" Then
        hc.ExecuteCredentials(job.GetRequest, taskCounter, job.Username, job.Password)
    Else
        hc.Execute(job.GetRequest, taskCounter)
       
    End If
    Return taskCounter
End Sub
 
Upvote 0

jgbozza

Member
Licensed User
Longtime User
I'm missunderstanding. Isn't the "problem" handled by If job.Success = True Then....Else [code for job timeout]?
My question is: Why there's an exception thrown when the job.success is false? I believe that job.success false is adressed when a job timeout is triggered. Am I wrong ?
 
Upvote 0
Top