HttpUtils2 Problem

salmander

Active Member
Licensed User
Longtime User
Sometimes, out of blue, I get this error while using HttpUtils2 module,
B4X:
in = File.OpenInput(HttpUtils2Service.TempFolder, taskId)

java.io.FileNotFoundException: /data/data/com.home.cafiq.test/cache/5: 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 com.home.cafiq.test.httpjob._getinputstream(httpjob.java:228)
    at com.home.cafiq.test.search._operationlistjob(search.java:4613)
    at com.home.cafiq.test.search._jobdone(search.java:3749)
    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:605)
    at android.os.Handler.dispatchMessage(Handler.java:92)
    at android.os.Looper.loop(Looper.java:137)
    at android.app.ActivityThread.main(ActivityThread.java:4424)
    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.io.FileNotFoundException: /data/data/com.home.cafiq.test/cache/5: open failed: ENOENT (No such file or directory)

does anyone have a clue?
 

salmander

Active Member
Licensed User
Longtime User
Every jobDone sub have this code snippet at the beggining.
B4X:
Sub checkUpdateJob(job As HttpJob)
   Log("checkUpdateJob loaded")
   If job.Success = False Then
      ToastMessageShow("Error fetching information from the Server.", True)
      Return
   End If
   Dim textreader1 As TextReader
   textreader1.Initialize(job.GetInputStream)
   Dim result As String
   result = textreader1.ReadAll
   textreader1.Close
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
ohhh I see. I think the order of the jobdone events are not same as they started. So that could be the reason... anyway, cheers for the help guys. I will debug it more and will try to find the cause and if I can prevent this error.
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
Sorry one more question? Apologies if its not related to the topic. But it is indeed related to httputils2.
Is it possible to use multipart post with httputils2 module? I can see a method call postFile but I also want to send some data with the post request. As of now, I am using MultiPartPost code module, but is this feature not in HttpUtils2 module?
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
I dont think you can do Mutlipart post using HttpUtils2 yet. You can probably modify the class to add the code (from the code module) yourself.
Multipart posts, require you to add some more headers and separators between the parts.
I dont know how large the file sizes are you are posting, depending on that you will have to think whether you want to post as bytes array or file stream.
 
Upvote 0

salmander

Active Member
Licensed User
Longtime User
Sorry, cant figure out how to use HttpUtils2 and multipart post. What method shall I use to send the data?
Download
Download2
PostFile
PostBytes
 
Upvote 0

RadCoder

Member
Licensed User
Longtime User
+1 I have the same problem occasionally and its problematic. Still looking into the cause and a workaround.
I had a serious bug with the original httputils where task ID's were getting assigned to the wrong return stream intermittently. I could't find out why and wrote my own httputils without using a service. Unfortunately each consumer had to handle the events and processing using module based routines but it fixed the problem
 
Upvote 0

RadCoder

Member
Licensed User
Longtime User
That was the thing I could never reproduce consistently, it may go 100 http calls before the bug would show. i caught it with extensive logging over time. Couldn't log a bug too hard to reproduce. But the original httputils issue was prevalent over time on all devices I tested with.

So far so good with httputils2 except for the file io exception. Still looking into it
 
Upvote 0

qsrtech

Active Member
Licensed User
Longtime User
I get the same issue sometimes as the orginal poster. I do check for success all the time. Even though I get this, the data seems to still come in correctly. I believe the error comes in the job class or http service so checking for success doesn't really make if dif in my observation. I don't have a lot of time to investigate the anomolie so if I happen to come accross some more details that will help I will post...
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…