iOS Question B4i app crash when implementing HttpJob and HttpUtils2Service

cwt

Active Member
Licensed User
Longtime User
I am creating an iOS app with B4i v6.80 and HttpJob v2.70 and HttpUtils2Service v2.70. Both HttpJob and HttpUtils2Service are being used as Code Modules.

I am trying to use the code below, as taken from the example:

B4X:
    Dim j As HttpJob
    j.Initialize("", Me)
    j.PostString(Main.ServerURL,PostString)
    Wait For (j) JobDone(j As HttpJob)
    If j.Success Then
        Log(j.GetString)
    End If
    j.Release

If I comment out this line: "Wait For (j) JobDone(j As HttpJob)" the app does not crash and the POST is received by my web server. With the line not commented out the app crashes every time the code is called.

Attached is the error log showing the error. Am I doing something wrong?
 

Attachments

  • Error Log.txt
    2.4 KB · Views: 153

ilan

Expert
Licensed User
Longtime User
i think the jobdone will be raised only by j.download function and not by j.PostString function.
 
Last edited:
Upvote 0

cwt

Active Member
Licensed User
Longtime User
Erel,

The reason I used the code module for HttpUtils2Service is that I need to change hc.Initialize("hc") to hc.InitializeAcceptAll("hc") so I do not have problems with the SSL certificate. Is there another way to do this?

I get the below error if I do not "AcceptAll" certificates. This is on my test web server. On the production web server I am also connecting to an IP address rather than a domain name, so I must "AcceptAll" in any circumstance.

ResponseError: The certificate for this server is invalid. You might be connecting to a server that is pretending to be ā€œ192.168.1.97ā€ which could put your confidential information at risk., status code: 0
 
Last edited:
Upvote 0

cwt

Active Member
Licensed User
Longtime User
Okay - I removed the HttpJob and HttpUtils2Service modules and activated the libraries for each - to get around the SSL certificate error I temporarily made my webs server HTTP instead of HTTPS and now no errors.

BUT - I need to set the POST content type in HttpJob to "text/xml" - how do I set the content type? And finally, how do I change the default timeout in HttpJob?

Thanks.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
to get around the SSL certificate error I temporarily made my webs server HTTP instead of HTTPS and now no errors.
I cannot help you if you ignore my answers. See the first search result. It takes exactly 10 seconds to enable "accept all".

BUT - I need to set the POST content type in HttpJob to "text/xml" - how do I set the content type?
Use the search feature. It works very good:
 
Upvote 0

cwt

Active Member
Licensed User
Longtime User
Erel,

You misunderstood me - I pay attention to your answers and I fully intend to utilize your advice on "accept all" - but I am doing this one step at a time because I added my own code to the HttpJob module for setting the content type and timeout.

And I always do a search for my questions before I post a question. I don't want to implement fixes that I do not understand. I have been using B4A for almost 5 years now and know the policies - converting my B4A app to B4i is taking a little time.
 
Upvote 0
Top