iOS Question Httpjob: Error reading from stream: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory


Licensed User
Longtime User
Hi All,

Please assist, I'm running a MySQL query with JRDC which hits the server and about 50% of the time works, the other 50% I receive the error below - No code changes in between.

Copying updated assets files (6)
response success
Unexpected event (missing RaisesSynchronousEvents): AFTER_SLEEP
Error occurred on line: 97 (HttpJob) ****See botom of page for line 97***
Error reading from stream: Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory" UserInfo={_kCFStreamErrorCodeKey=2, _kCFStreamErrorDomainKey=1}
Stack Trace: (
CoreFoundation __exceptionPreprocess + 242
libobjc.A.dylib objc_exception_throw + 48
CoreFoundation -[NSException initWithCoder:] + 0
B4i Example -[B4IInputStream ReadBytes:::] + 325
B4i Example -[B4IFile Copy2::] + 302
B4i Example -[B4IBit InputStreamToBytes:] + 188
B4i Example -[ResumableSub_dbrequestmanager_HandleJobAsync resume::] + 452
B4i Example -[b4i_dbrequestmanager _handlejobasync:::] + 569
B4i Example -[ResumableSub_main_GetRecord resume::] + 2108
CoreFoundation __invoking___ + 140
CoreFoundation -[NSInvocation invoke] + 305
B4i Example +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1519
B4i Example -[B4IShell runMethod:] + 380
B4i Example -[B4IShell raiseEventImpl:method:args::] + 1566
B4i Example __40-[B4IShell raiseEventImpl:method:args::]_block_invoke + 40
libdispatch.dylib _dispatch_call_block_and_release + 12
libdispatch.dylib _dispatch_client_callout + 8
libdispatch.dylib _dispatch_main_queue_callback_4CF + 1075
CoreFoundation __CFRunLoopRun + 2772
CoreFoundation CFRunLoopRunSpecific + 567
GraphicsServices GSEventRunModal + 139
UIKitCore -[UIApplication _run] + 928
UIKitCore UIApplicationMain + 101
B4i Example main + 104
dyld start_sim + 10
??? 0x0 + 8664179925
??? 0x0 + 8664158208
B4i Example __dso_handle + 0

Error code line
96: Public Sub GetInputStream As InputStream
97: Return res.GetInputStream
98: End Sub


Licensed User
Longtime User
Not sure if this helps. but I noticed now that if I remove the "For Each records() As Object In res.Rows" portion the error goes away, but then I cannot work with the data? Or are there another way of accessing the rows returned?

The error happens on the first http request to JRDC, if I do not get the error the app runs without issue with thousands of requests.

Also the SQL is only a get: sql.select_all=SELECT ID, Name, Status2, Temperature, Humidity FROM home;

Sub GetRecord (id As String)
    Dim req As DBRequestManager = CreateRequest
    Dim cmd1 As DBCommand = CreateCommand("select_all", Null)
    Dim bp_g As Bitmap
    bp_g.Initialize(File.DirAssets, "green.jpg")
    Dim bp_r As Bitmap
    bp_r.Initialize(File.DirAssets, "red.jpg")
    Wait For (req.ExecuteQuery(cmd1, 0, Null)) JobDone(j As HttpJob)
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        For Each records() As Object In res.Rows
            'Dim device_id As String = records(0) 'records(0) 'or records(result.Columns.Get("name"))
            Dim device_name As String = records(res.Columns.Get("Name"))
            Dim device_open As String = records(res.Columns.Get("Status2"))
            Dim device_temp As String = records(res.Columns.Get("Temperature"))
            'Dim device_hum As String = records(res.Columns.Get("Humidity"))
            If device_name = "Kitchen" And device_open = "0" Then
            End If
            If device_name = "Bedroom Temp sens" Then
                Dim s_temp As String
                s_temp = device_temp.SubString2(0,2) &","&device_temp.SubString2(2,3) & "°c"
                slaapkamer_temp_lbl.Text = s_temp
            End If
        Log("ERROR: " & j.ErrorMessage)
    End If
Upvote 0


Licensed User
Longtime User
Added sleep(5) after line 12 and the issue seems to be resolved. Seems like I need some time for the result to be received before it's processed.
Upvote 0