iOS Question httpjob fail

tufanv

Expert
Licensed User
Longtime User
Hello,

Httpjob result sometimes fails so, the app executes the jobdone fail , which displays a "Network Error" message in my app. Nearly 3 of 10 executes fails so this disturbs users very much. Only way i could find was to add the executeremotequerry line which is failed to jobdone fail , so if the job fails the command is executed again. Is there any better way so that httpjob not fail or retry again without me adding the code to if fail . My vps is quite fast and quality but the jobdone fails nearly %30 of all times. Can you suggest me anything for this ?

TY
 

tufanv

Expert
Licensed User
Longtime User
This is a network problem. The best thing that you can do is to send the request again.
My current structure is like this:
B4X:
JobDone2(Job)
    Log(Job.JobName)
    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

than there are many CASE "JOBNAME"
and at the end i have the else where i need to repeat the action if failed but this is a shared else, i mean it is a if fail for every job. Is there any way i can do something like this on if job.success = true .. ELSE :

Check the jobname failed , and repeat the job again by going to case JOBNAME again
?

TY
 
Upvote 0

tufanv

Expert
Licensed User
Longtime User
You need to send the job again with Job.Download or a similar method. This will cause JobDone to be raised again later when the response is available.

You should however use CallSubPlus to try the job again in a few seconds instead of immediately.
What I could not understand is under jobfail section can I use stg to pull the name of the failed job and direct the app to jobdone again to repeat the corresponding job again. For example the name oj the job that failed is "test1" Can I do something like repeat the job that sent the request again or do i have to manually add all the requests under fail section
 
Last edited:
Upvote 0

ilan

Expert
Licensed User
Longtime User
What I could not understand is under jobfail section can I use stg to pull the name of the failed job and direct the app to jobdone again to repeat the corresponding job again. For example the name oj the job that failed is "test1" Can I do something like repeat the job that sent the request again or do i have to manually add all the requests under fail section


you can declare a variable like "dim failedjob as string" then on every job send action you set failedjob to the job you just sent
like:

B4X:
    Sub Button1_Click
              failedjob = "job6"
        Dim Job6 As HttpJob
        Job6.Initialize("Job6", Me)
        Job6.download(domain)
    End Sub

and then in jobdone you check in job success false the string jobfailed

B4X:
Private Sub JobDone(Job As HttpJob)
    If Job.Success Then
        Dim res As String
        res = Job.GetString
        Log("Back from Job:" & Job.JobName)
        Log("Response from server: " & res)
        Select Job.JobName
            Case "Job1"
            '....
            Case "Job2"
            '....
        End Select
    Else
        Log("Error: " & Job.ErrorMessage)
        select jobfailed
            case "Job6"
                Button1_Click 'Send Job6 again
            case "job7"
            '....
            End Select
    End If
    Job.Release
End Sub

anyway as erel said you should call again the job in few second and not immediately.
you can use a timer for that, and also you should limit it to max 3 times (or whatever you think) so you wont have an endless job sending process
 
Upvote 0
Top