HttpUtils Problem

torpedo

Member
Licensed User
Longtime User
i have a problem with the HttpUtils.

i try to load the code from a internet site. i use HttpUtils as in the example from Eral

but after the code-line:
HttpUtils.Download ("Job1", URLTabelle)
the programm ends. it will never come back to the next code line in my programm.

i try to explane my problem in the german forum, but nobody can help me there. they tested my testprogramm an after that they told me, thats maybe a problem with HttpUtils.

here the link with my testprogramm in the german forum:
http://www.b4x.com/forum/germa...schreiben.html
ore in the attachement

maybe somone have time to watch in the code.

thanks for answer
torpedo
 

Attachments

  • InetInDatei.zip
    8.7 KB · Views: 188

Merlot2309

Active Member
Licensed User
Longtime User
Hi Torpedo,

When you change the url to -http://google.ch-, as Erel already mentioned,
the fix works fine.

When you move the line
B4X:
edtText.Text = s
to the Sub JobDone, just before End Sub, it does work.

Greets,

Helen.
 
Upvote 0

miguelconde

Member
Licensed User
Longtime User
Httutils problem

Again you should check the logs and see why it fails.
Guy's how do you resolved this problem?, i have the same problem. IN the log i see everything fine: Service (httputilservice) create - start - destroy, run well,
my file donwloading do it fine from the server, but not code run after the httputils.download method, the sub create die in that line.
 
Upvote 0

ostau

Member
Licensed User
Longtime User
Problem with Post

In sub Main I have the following code (where JobName is as string)

HttpUtils.CallbackActivity = "HttpWebService"
HttpUtils.CallbackJobDoneSub = "JobDone"
HttpUtils.CallbackUrlDoneSub = "UrlDone"
HttpUtils.PostString(JobName,URL,Parameters)

The applications stops in HttpUtilsSerive.ProcessnextTask when calling Http_UtilsService -> ProcessNexttask->CallSub2(HttpUtils.CallbackActivity, HttpUtils.CallbackJobDoneSub, HttpUtils.Job)

because CallSub2 doesn´t exist (neither in HttpUtils, nor in Http_UtilsService).
Any idea what´s wrong?

Oskar
 
Upvote 0

ostau

Member
Licensed User
Longtime User
Correction

It´s not in Sub Main, it´s in Sub HttpWebService, so HttpWebService is correct.
 
Upvote 0

ostau

Member
Licensed User
Longtime User
Hi Erel, you are so quick with your response, I didn´t see your replay before I answered.
I moved the code into a new Activity Named HttpWebService, changed the CallbackActivity accordingly and now it jumpes into routine JobDone (as expected).
Once again, I really appriciate your Support!

Kind regards, Oskar
 
Upvote 0

Andras

Active Member
Licensed User
Longtime User
I'm having the same problem and finding exactly the same error message.

Here's the relevant code - any ideas?

B4X:
Sub BtnLoad_Click
   datasrc = "http://caron-promotions.co.uk/"
    ToastMessageShow("Downloading Update - May take a minute or so. . .",True)
   dlfilename= "places.db"

 '   Log("Database = " & datasrc)

    HttpUtils.CallbackActivity = "Main" 'Current activity name.
    HttpUtils.CallbackJobDoneSub = "JobDone"
    HttpUtils.Download("Job2", dlfilename)
    
End Sub

Sub JobDone (Job As String)
    Dim updatestatus As String
    Dim In As InputStream, Out As OutputStream
      Log(dlfilename)
    If HttpUtils.IsSuccess(dlfilename) Then
        Select Job 
            Case "Job1"
                  '......
            Case "Job2"
                ' Handling input stream
                '!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                If HttpUtils.IsSuccess(dlfilename) Then

                    In = HttpUtils.GetInputStream(dlfilename)
                    
                    Out = File.OpenOutput(File.DirDefaultExternal, "update.db", False)
                     File.copy2(In,Out )
                    Out.Flush
                    Out.Close

                    File.copy(File.DirDefaultExternal,"workingfilename",File.DirDefaultExternal,"workingfilename.bak")
                    File.copy(File.DirDefaultExternal,"newfilename",File.DirDefaultExternal,"workingfilename")
                    '
                    ToastMessageShow("New Data downloaded OK!", False)
                Else
                    ToastMessageShow("Problem Downloading Data!", False)
                End If    
        End Select
     Else
        Button_Load.Enabled = False
        ToastMessageShow("Can't Connect to Server: Check Internet Connection or Try Later!",True)        
    End If
End Sub

Thanks!

John
 
Last edited by a moderator:
Upvote 0

Andras

Active Member
Licensed User
Longtime User
Thanks, Erel, and apologies for not making myself clear - it's the same error message, in effect, as Torpedo was having as the beginning of this thread:

Error. Url:places.db.
Message=javalang.IllegalStateException:Target host must not be null, or set in parameters

John

Edit - sorry for the sticking-out tongue; how do I turn the smileys off?

Additional point - the httputils example doesn't actually do anything on either the emulator or a device here, although I can work out what it ought to do; so I don't feel that just copying it is likely to be helpful! Any suggestions there either?

Thanks!

John

J
 
Last edited:
Upvote 0
Top