Services Question

jddiven

Member
Licensed User
Longtime User
I would eventually like to load a CSV file from an attached network to use in an app.

To try to understand better, I've been playing with the Services:download tutuorial. When attached to the internet it works fine but when I attach to my network and substitute

DownloadService.URL = http://###.###.#.###/designer1.png" (with ###.###.##.### being my network's IP address)

for

DownloadService.URL = http://www.b4x.com/basic4android/images/designer1.png"

I get a "Error downloading file: Object Not Found" message. The file is there! What am I doing wrong?

Thanks for any help.
 

jddiven

Member
Licensed User
Longtime User
Thank You

Thanks for the suggestion. I'll work on it this morning.

Yes, I do have a web server running.
 
Upvote 0

jddiven

Member
Licensed User
Longtime User
Thank you

Thank you for the suggestion.

When I try it I get an "Under Construction" message. I've taken Erel's httpServices example and simplified it to the point that it only gets the image url. When I run it using the www.basic4ppc...etc. logo it works but when I using a .png file on my local server, I still get a blank screen.

Thanks again. Any suggestion would be appreciated.
 
Upvote 0

jddiven

Member
Licensed User
Longtime User
I'm getting closer.

Thanks for the suggestion.

At first I couldn't see the file but when I moved it to the inetpub/wwwroot folder on the server it was visible.

However, the app still doesn't work.

Thanks Again.
 
Upvote 0

warwound

Expert
Licensed User
Longtime User
If i was you then i think the next thing i'd look at is your network configuration.

BUT if the Android browser can access the image via HTTP on port 80 then i see no technical reason why your B4A app can't do the same.

Perhaps you can upload your project - or the relevant parts of it - and we'll see if there's anything obviously wrong in your code?

Martin.
 
Upvote 0

jddiven

Member
Licensed User
Longtime User
Still not working

Attached find a zip file of the test program. With line 4 commented and line 5 uncommented it works.

As is, (with the IP) I get the message: "The application Http Utils (process anywheresoftware.b4a.samples.httputils) has stopped unexpectedly. Please try again. Please try again.

I thought at first that the .png that I was trying to load was too big. It is 1442x1451 907kb while the file on the internet is 235x314 26314 bytes but when I tried a 166x139 4.69kb .png, it too crashed.

Again thanks for all your help.

Doug
 

Attachments

  • notworking.zip
    8.2 KB · Views: 225
Upvote 0

warwound

Expert
Licensed User
Longtime User
Hi.

You code creates an error:

Caused by: java.lang.RuntimeException: java.lang.IllegalArgumentException: Illegal character in schemeSpecificPart at index 5: http:\\xxx.xxx.x.xxx\logo.png

Don't use the Window file scheme \ for the local network URL, stick to the standard HTTP scheme /.

This code works on an emulator but NOT on my ZTE Blade:

B4X:
 'Activity module
Sub Process_Globals
   Dim ImageUrl, PostUrl As String
End Sub

Sub Globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
   If FirstTime Then
      '   192.168.1.2 is my computer
      '   my ZTE Blade is always assigned an IP address of 192.168.1.4 on my local network
      ImageUrl = "http://192.168.1.2/google.gif"
      '   ImageUrl = "http://www.b4x.com/android/images/logo2.png"
   End If
   
   HttpUtils.CallbackActivity = "Main"
   HttpUtils.CallbackJobDoneSub = "JobDone"
   HttpUtils.CallbackUrlDoneSub = "UrlDone"
   HttpUtils.Download("GET Job1", ImageUrl) 'start
End Sub

Sub Activity_Resume
   'Check whether a job has finished while the activity was paused.
   If HttpUtils.Complete = True Then JobDone(HttpUtils.Job)
End Sub
Sub UrlDone(Url As String)
   'Log(Url & " done")
End Sub
Sub JobDone (Job As String)
   If Job = "GET Job1" Then
      If HttpUtils.IsSuccess(ImageUrl) Then 
         Dim b As Bitmap
         b = HttpUtils.GetBitmap(ImageUrl)
         Activity.SetBackgroundImage(b)
      Else
         '   whats the error?
         
      End If
   End If
   HttpUtils.Complete = False 'Turn off the complete flag so we won't handle it again if the activity is resumed.
End Sub

When i run that on my Blade the log shows:

Error. Url=http://192.168.1.2/google.gif Message=org.apache.http.conn.ConnectTimeoutException: Connect to /192.168.1.2:80 timed out

I opened my Blade's Android browser and tried to browse to the homepage on my computer using the local IP address (Apache webserver installed on port 80 on my computer).
The Android browser says Webpage not available

You local network must be configured differently as you said that you could access your computer webserver from the Android browser using the local IP address.

So try your code again using forward slash in URL instead of backslash and see if it works.

If wanted to make the code work on my network i'd make use of my routers built in Dynamic DNS client.
I have an account with Managed DNS | Outsourced DNS | Anycast DNS and i can enter that account in my router settings and my dyn.com alias is always updated (by the router) to my current dynamic IP address assigned by my ISP.

So i'd simply change the local network address to my dyn.com alias.

Martin.
 
Upvote 0

jddiven

Member
Licensed User
Longtime User
Success

Martin

Thank You, Thank You, Thank You

Before yesterday I had been using the forward slashes but the program would just sit on a blank screen. Yesterday when I tried the back slashes the program vaporized. In my ignorance, I thought that that was progress.

This morning, when I returned to the forward slashes, the program worked.

I'm still not sure what I had been doing wrong other than that but I can't argue with success.

Now all I need to do is to figure out how to get my CSV file from the server.

Again Thanks!!!!

Doug
 
Upvote 0
Top