HTTP2UTILS errors and crashes

Rhonan

Member
Licensed User
Longtime User
Hi all,

I guess I'm doing something wrong as the new http2utils routines are meant to be robust.. so i hope you can help.

I'm getting a lot of errors now that seem to be escaping my error handling and crashing my app. These are normally when there's a problem with the data connection. I've seen crashes when I've had a 500 error reported, when i've hit firewalls, or ECONNRESET, or when i apparently just can't connect. THe following is the logs from a bad connection. I hope you can help me error-trap these correctly so i won't crash the app. Currently I'm just error trapping using the success flag of the http function.

logs below..

thank you
Ronan


-------------

* Activity (main) Create, isFirst = true **


** Activity (main) Resume **


** Service (httputils2service) Create **


** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (httputils2service) Start **
** Service (http_functions) Create **


** Service (http_functions) Start **


httpjob_getstring2 (B4A line: 108)


tr.Initialize2(File.OpenInput(HttpUtils2Service.TempFolder, taskId), Encoding)



java.io.FileNotFoundException: /data/data/me.tooa.alphad/cache/3: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:406)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:197)
at me.tooa.alphad.httpjob._getstring2(httpjob.java:302)
at me.tooa.alphad.httpjob._getstring(httpjob.java:277)
at me.tooa.alphad.http_functions._jobdone(http_functions.java:140)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:881)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at anywheresoftware.b4a.Msgbox.waitForMessage(Msgbox.java:211)
at anywheresoftware.b4a.Msgbox.debugWait(Msgbox.java:156)
at anywheresoftware.b4a.debug.Debug.wait(Debug.java:209)


at anywheresoftware.b4a.debug.Debug.reachBP(Debug.java:256)
at anywheresoftware.b4a.debug.Debug.ErrorCaught(Debug.java:145)
at me.tooa.alphad.httpjob._getstring2(httpjob.java:320)
at me.tooa.alphad.httpjob._getstring(httpjob.java:277)
at me.tooa.alphad.http_functions._jobdone(http_functions.java:140)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:881)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:390)
... 32 more
httpjob_getstring2 (B4A line: 108)
tr.Initialize2(File.OpenInput(HttpUtils2Service.TempFolder, taskId), Encoding)



java.io.FileNotFoundException: /data/data/me.tooa.alphad/cache/1: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:406)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:197)
at me.tooa.alphad.httpjob._getstring2(httpjob.java:302)
at me.tooa.alphad.httpjob._getstring(httpjob.java:277)
at me.tooa.alphad.http_functions._jobdone(http_functions.java:140)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:881)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:390)
... 18 more
java.lang.RuntimeException: java.lang.RuntimeException: java.io.FileNotFoundException: /data/data/me.tooa.alphad/cache/1: open failed: ENOENT (No such file or directory)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:884)
at android.os.Handler.handleCallback(Handler.java:608)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:5045)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.RuntimeException: java.io.FileNotFoundException: /data/data/me.tooa.alphad/cache/1: open failed: ENOENT (No such file or directory)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:199)
at anywheresoftware.b4a.keywords.Common$4.run(Common.java:881)
... 9 more
Caused by: java.io.FileNotFoundException: /data/data/me.tooa.alphad/cache/1: open failed: ENOENT (No such file or directory)
at libcore.io.IoBridge.open(IoBridge.java:406)
at java.io.FileInputStream.<init>(FileInputStream.java:78)
at anywheresoftware.b4a.objects.streams.File.OpenInput(File.java:197)
at me.tooa.alphad.httpjob._getstring2(httpjob.java:302)
at me.tooa.alphad.httpjob._getstring(httpjob.java:277)
at me.tooa.alphad.http_functions._jobdone(http_functions.java:140)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:170)
... 10 more
Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
at libcore.io.Posix.open(Native Method)
at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
at libcore.io.IoBridge.open(IoBridge.java:390)
... 18 more
 

Rhonan

Member
Licensed User
Longtime User
Thanks Erel, this is the code, it's in a code module.

----------




B4X:
Sub JobDone(Job As HttpJob)
   Dim message As String
   Dim str1,str2,str3 As String
   Dim list1 As List
   Dim vals As Map
   Dim i,j As Int

'      
   Main.http_message = Job.GetString    ' for debug purposes
   message = Job.GetString

   If (Main.FLAG_DEBUG > 0) Then ToastMessageShow(Job.JobName,False)
   
   
   If Job.Success = True Then        
   
      Select Job.JobName            
      '####################################################
      '####################################################
      
      Case "advertupdate"
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow("ADVERT: STATUS UPDATE REQUEST SENT SUCCESSFULLY",False)
         common_code.parse_adsupdate
         
      '####################################################
      '####################################################
      Case "surveysubmit"                'print the result to the logs                
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow("SURVEY: Update Sent (TARGET HIT SUCCESSFULLY)",False)
      
      '####################################################
      '####################################################
      Case "statusupdate"
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow(Job.JobName,False)
         common_code.parse_statusupdate

      '####################################################
      '####################################################   

      Case "newsupdate"
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow(Job.JobName,False)
         Main.FLAG_NEWSLOADED = 1
         common_code.parse_newsupdate

      '####################################################
      '####################################################
      Case "newuser"
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow(Job.JobName,False)
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow(Main.http_message,True)

      
      '####################################################
      '####################################################   

      Case "advertaction"
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow(Job.JobName,False)
         'ToastMessageShow(Main.http_message,True)


      '####################################################
      '####################################################   
      
      Case "surveyupdate"
         If (Main.FLAG_DEBUG > 0) Then ToastMessageShow(Job.JobName,False)
         common_code.parse_surveyupdate

      '####################################################
      '####################################################         
      End Select
   
      
      
      
      
      '####################################################      
      '# NOW FOR THE FAILURES
      '####################################################
   Else
        Select Job.JobName            
      '####################################################
      Case "advertupaction"
         ToastMessageShow("ADVERT: Action Sent (ERROR: " & Job.ErrorMessage & ")",False)
   
      '####################################################
      Case "surveyupaction"
         ToastMessageShow("SURVEY: Action Sent (ERROR: " & Job.ErrorMessage & ")",False)
   
      '####################################################
      Case "surveysubmit"                'print the result to the logs                
         ToastMessageShow("SURVEY: Update Sent (ERROR: " & Job.ErrorMessage & ")",False)

      '####################################################
      Case "newsupdate"                'print the result to the logs                
         ToastMessageShow("NEWS: Download Request (ERROR: " & Job.ErrorMessage & ")",False)
      
      '####################################################
      Case "advertupdate"                'print the result to the logs                
         ToastMessageShow("ADVERT: Update Request (ERROR: " & Job.ErrorMessage & ")",False)
      
      '####################################################
      Case Else
         ToastMessageShow("Error: " & Job.ErrorMessage, False)    
   '####################################################
      End Select         
   End If

      
   
   Job.Release
End Sub
 
Upvote 0

Rhonan

Member
Licensed User
Longtime User
"Main.http_message = Job.GetString"

Erel,

thanks for replying. The active code is the above line at the top of the file. All the subsequent subroutines are processing this global text string.

Is that what you were asking for?
 
Upvote 0

Rhonan

Member
Licensed User
Longtime User
I've noticed that I'm asking for the "job.getstring" before checking for job success. Could this be the problem?

R



"Main.http_message = Job.GetString"

Erel,

thanks for replying. The active code is the above line at the top of the file. All the subsequent subroutines are processing this global text string.

Is that what you were asking for?
 
Upvote 0

enrico

Active Member
Licensed User
Longtime User
I have this error :
B4X:
java.lang.RuntimeException: Error loading bitmap.
httpjob_getbitmap (B4A line: 118)
b = LoadBitmap(HttpUtils2Service.TempFolder, taskId)
java.lang.RuntimeException: Error loading bitmap.

This is my JobDone :
B4X:
Sub JobDone (Job As HttpJob)
    If Job.Success = True Then
      ImageView1.Bitmap = ImageJob(i).GetBitmap
   Else
      Bitmap1(i).InitializeSample(File.DirAssets,"transparent.png", SymbolWidth, SymbolHeight)
      ImageView1.Bitmap = Bitmap1(i)
   End If
   Job.Release
End Sub
 
Upvote 0

enrico

Active Member
Licensed User
Longtime User
I've done this :

B4X:
'Initialize ImageJob Array 
For i = 0 To 29
     ImageJob(i).Initialize("ImageJob(" & i & ")", Me)  
End If

'Assign Links
ImageLink(0) = Main.imgDir & "image0.png"
ImageLink(1) = Main.imgDir & "image1.png"
ImageLink(2) = Main.imgDir & "image2.png"
ImageLink(3) = Main.imgDir & "image3.png"
ImageLink(4) = Main.imgDir & "image4.png"
ImageLink(5) = Main.imgDir & "image5.png"
.......

I want to put those images in a scrollview, so :
B4X:
Panel0 = ScrollView1.Panel
For i = 0 To 29
        Dim Panel1 As Panel
        Panel1.Initialize("")
        Panel1.RemoveView
        PanelHeight = 99dip
        Panel0.AddView(Panel1,0,PanelTop,ScrollView1.Width,PanelHeight)
        ImageView1.Initialize("ImageView1")
        ImageJob(i).Download(ImageLink(i))
        ImageView1.Gravity = Gravity.Fill
        Panel1.AddView(ImageView1,5dip,17dip,SymbolWidth,SymbolHeight)
        PanelTop=PanelTop+PanelHeight+1dip
Next
Panel0.Height=PanelTop

What I see from the log is that it seems that Jobdone always processes image4.png (???), it does it 5 times (always i = 4) and then stops with error :

httpjob_getbitmap (B4A line: 118)
b = LoadBitmap(HttpUtils2Service.TempFolder, taskId)
java.io.FileNotFoundException: /data/data/...packagename.../cache/5 (No such file or directory)

This error appears 5 times consecutively before program stops.
 
Upvote 0

enrico

Active Member
Licensed User
Longtime User
Sorry but I gave it up and I'm doing it with WebView (and it works), so I've modified all the code.
For sure it was my fault to not understand correctly how httputils2 works.
Maybe I will try later to investigate it.
 
Upvote 0
Top