HttpUtils overload problem

BowTieNeck

Member
Licensed User
Longtime User
I've been testing the attached app for user abuse ie continually hitting the 'Previous' label before the current results have been retrieved/loaded.
The way this is supposed to work is the current week's lottery results are retrieved and displayed on the Main Activity when the app is loaded. Then by clicking 'Previous' older results will be retrieved and displayed.
This works ok if you wait for each set of results to be displayed and maybe up to a dozen times or so if you hit the 'Previous' label fairly rapidly. But at some point the app fails with the Force Close/Wait display.
I added Enabled = False to the labels that are clickable on the Activity, when there's a request for another set of data, thinking that would stop a new request being created but that didn't seem to make any difference.
This is part of the log (in this case we got to 32 sets of data before it collapsed):

Previous key clicked - Drawsubscript = 31
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '40e64dc0 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
Starting Job: Job3
** Service (httputilsservice) Create **
** Service (httputilsservice) Start **
dispatchTouch::touch event's action is 1
Delivering touch to current input target: action: 1, channel '40e64dc0 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
26997
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '40e64dc0 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
Sending finished signal for input channel '40e64dc0 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (client)' since it is being unregistered while an input message is still in progress.
** Service (httputilsservice) Destroy **
Ignoring finish signal on channel that is no longer registered.
GC_CONCURRENT freed 479K, 51% free 3395K/6791K, external 516K/1004K, paused 15ms+3ms
dispatchTouch::touch event's action is 1
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '4051a788 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 1
Delivering touch to current input target: action: 1, channel '4051a788 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
Previous key clicked - Drawsubscript = 32
Starting Job: Job3
** Service (httputilsservice) Create **
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'


dispatchTouch::touch event's action is 1
Delivering touch to current input target: action: 1, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 1
Delivering touch to current input target: action: 1, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 1
Delivering touch to current input target: action: 1, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 1
Delivering touch to current input target: action: 1, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 0
Delivering touch to current input target: action: 0, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'
dispatchTouch::touch event's action is 1
Delivering touch to current input target: action: 1, channel '4058bf70 bowtieneck.uklottochecker/bowtieneck.uklottochecker.main (server)'

It looks like it's looping on dispatchTouch 1 then 0.

Any help would be greatly appreciated.

Thanks,
Chris
 

Attachments

  • UKLottoChecker.zip
    25.4 KB · Views: 121

BowTieNeck

Member
Licensed User
Longtime User
Code extracts

Here's the code for the Previous button (which is actually a label):
B4X:
Sub lblPrev_Click
   Log("Previous key clicked - Drawsubscript = " & DrawSubscript)
   If DrawSubscript < 50 Then
      'set the ticket colours back to blue
      ResetTicketColours
      'subtract 1 from the draw subscript to point to the previous draw
      DrawSubscript = DrawSubscript + 1
      'if we get to one end or the other of the 6 months of lotto draws then we need to make the text
      'of the relevant button grey to indicate we can't go any further. Otherwise button text is white.
      CheckButtonTextColour
      If PrizeFor3(DrawSubscript) = 0 Then
         lblPrev.Enabled = False
         lblAddEdit.Enabled = False
         lblNext.Enabled = False
         pnlMenu.Enabled = False                        'don't allow button clicking until the data's downloaded
                                                                  'this gets reenabled in the Job3 code
         ProgressDialogShow("Getting " & LastDrawDate(DrawSubscript))
         DoEvents
         Activity.Invalidate   'force the 'hourglass' to be displayed
         DoEvents
         HttpUtils.CallbackActivity = "Main" 'Current activity name.
         DoEvents
         HttpUtils.CallbackJobDoneSub = "JobDone"
         DoEvents
         'if the prize for 3 matching tickets hasn't been set for this draw then none of the prize values has been set
         'so read the relevant web page and store the prizes in the array for this draw
         LotteryPrizesURL = "http://www.lottery.co.uk/results/result.asp?LotteryID=2&ResultID=" & ResultID(DrawSubscript)
         HttpUtils.Download("Job3", LotteryPrizesURL)
         DoEvents
'         ProgressDialogHide   'remove the 'hourglass'
      Else
         'the prize details have been read so display the winning numbers on the screen with the date including the day
         'then check for matches
         SetDrawDetails
         CheckTickets
      End If
   Else
      Msgbox("We can only go back 6 months","UK Lotto Checker")
   End If
End Sub

There weren't any error messages. I edited hc_ResponseError & HandleError in HttpUtilsService to include a log message if either of them was entered as follows:

Sub hc_ResponseError (Response As HttpResponse, Reason As String, StatusCode As Int, TaskId As Int)
Log("hc_ResponseError Response = " & Response.GetString("UTF8") & _
      ", StatusCode = " & StatusCode & ", TaskId = " & TaskId)
   countWorking = countWorking - 1
   finishTasks = finishTasks + 1
   HandleError(TaskId, Reason)
   If Response <> Null Then
      Log(Response.GetString("UTF8"))
      Response.Release
   End If
   ProcessNextTask
End Sub
Sub HandleError(TaskId As Int, Reason As String)
Log("HandleError TaskId = " & TaskId & ", Reason = " & Reason)
   Dim link As String
   link = taskToRequest.Get(TaskId)
   Log("Error. Url=" & link & " Message=" & Reason)
End Sub
But neither message appeared in the log.

I'm sorry the code looks pretty unreadable here. I'm not sure how to include the tabbing & different colours, if that's possible.
 
Last edited by a moderator:
Upvote 0

BowTieNeck

Member
Licensed User
Longtime User
That's fantastic Erel. I don't understand why, but removing all those DoEvents makes it work.
I also don't understand why the code looks ok above. When I did a preview of the post with that code in it was all left aligned, ie no indents etc.
 
Upvote 0
Top