iOS Question HTTPUtils2 only working when stepping in debug?

MotoMusher

Active Member
Licensed User
Longtime User
I have no idea why this is happening.

I am using v2.1 of httpjob and httputils2service.

I call
B4X:
    Dim j As HttpJob
    If j.IsInitialized = False Then
        j.Initialize("SecReq", Me)
    End If

    j.PutFile("http://centers.bubblergps.com/api/user", Main.MyFilePath, "tempsec.json")

If I put a breakpoint there and step through line by line it works every time, and comes back to my jobdone event.

If I do not have a breakpoint, if fails ALMOST every time (when it doesn't the jobdone event isn't fired, but doesn't error). Error follows.
Error response: , status code: 415
Error occurred on line: 27 (HttpUtils2Service)
*** -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[3]
Stack Trace: (
CoreFoundation <redacted> + 150
libobjc.A.dylib objc_exception_throw + 38
CoreFoundation <redacted> + 292
CoreFoundation <redacted> + 44
Centers -[b4i_httputils2service _completejob::::] + 514
Centers -[b4i_httputils2service _hc_responseerror::::] + 1670
CoreFoundation <redacted> + 68
CoreFoundation <redacted> + 292
Centers +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1786
Centers -[B4IShell runMethod:] + 574
Centers -[B4IShell raiseEventImpl:method:args::] + 2212
Centers -[B4IShellBI raiseEvent:event:params:] + 1340
Centers __50-[B4I raiseEventFromDifferentThread:event:params:]_block_invoke + 74
libdispatch.dylib <redacted> + 10
libdispatch.dylib <redacted> + 22
libdispatch.dylib <redacted> + 1524
CoreFoundation <redacted> + 8
CoreFoundation <redacted> + 1574
CoreFoundation CFRunLoopRunSpecific + 520
CoreFoundation CFRunLoopRunInMode + 108
 

Kwame Twum

Active Member
Licensed User
Longtime User
I have no idea why this is happening
Which of these are you using please?
Untitled-1.png

And are you testing on a real device or emulator?
 
Upvote 0

AHilton

Active Member
Licensed User
Longtime User
I'm having the same problem as MotoMusher except I'm doing a ServerJob.PostString() instead of his .PutFile()

I've traced it back to the HttpJob Modules' Complete Sub ...
B4X:
Public Sub Complete (res1 As HttpResponse)
    res = res1
    Log("HTTPJob Target: " & target)
    CallSub2(target, "JobDone", Me)
End Sub

When things work correctly, target holds an object reference. When it doesn't, target holds nothing. The HTTPJob.initialize gets the TargetModule object but, somehow, that gets lost between Initiliaze and the Complete subs.

If I set a debug break on: "res=res1" then everything works just fine. Otherwise, it fails more times than not.


B4i v2.30, IPhone 6 - iOS 9.2
 
Upvote 0
Top