Android Question OkHttp and https

cdsnl

Member
Licensed User
Longtime User
Hi,
Using B4A 11.50.

When I use OkHttp and OkHttpUtils2 to do a poststring to an http it works fine.
When I do the same on https I get the error:
ResponseError. Reason: java.io.IOException: Android internal error, Response:
java.io.IOException: Android internal error

When I remove OkHttoUtils2 from my project and add the files HttpJob.bas and HttpUtils2Service.bas then both http and https are not working any more, and will give the same error.

If I change the following code
hc.Initialize("hc")
into
hc.InitializeAcceptAll("hc")
I get the same errors.

I put in a Log line in Service_Create to make sure it uses the correct code.

Note: the http and https uses the same software. The http is a server on the LAN, the https is a server on the internet.

Please advice

Thank you.
Andre
 
Solution
Hi Manfred,
Sorry for the delay, I was out for a couple of days.
But I found what the issue was when I was making a sample project.

When I do this.
j.PostString("https://sub_domain.domain.com/api","ABC")
It goes wrong and I get the error
ResponseError. Reason: java.io.IOException: Android internal error, Response:
java.io.IOException: Android internal error

When I do this
j.PostString("https://subdomain.domain.com/api","ABC")
It goes OK.

It seems that underscores in the url are not handle well. In other applications, like postman, it is no problem to use underscores.

Best regards
Andre

DonManfred

Expert
Licensed User
Longtime User
DELETE the old and deprecated(!!) httputils module and Service.

Switch to okhttputils2 and use this.
If you run into a problem;. Create a new thread with enough details (post a project showing the problem). Also post the FULL error/stacktrace. There must be one!
 
Upvote 0

cdsnl

Member
Licensed User
Longtime User
Still the same error.
What did I do:
I have check OkHttp and OkHttpUtils2 in the library manager
I have removed the two .bas files from the project which had add from the early mentioned ticket.
And I have deleted 4 files http.* and HttpUtils2.* files from the Internal Library directory.

Brdgs
Andre
 
Upvote 0

cdsnl

Member
Licensed User
Longtime User
Hi Manfred,
Sorry for the delay, I was out for a couple of days.
But I found what the issue was when I was making a sample project.

When I do this.
j.PostString("https://sub_domain.domain.com/api","ABC")
It goes wrong and I get the error
ResponseError. Reason: java.io.IOException: Android internal error, Response:
java.io.IOException: Android internal error

When I do this
j.PostString("https://subdomain.domain.com/api","ABC")
It goes OK.

It seems that underscores in the url are not handle well. In other applications, like postman, it is no problem to use underscores.

Best regards
Andre
 
Upvote 0
Solution

DonManfred

Expert
Licensed User
Longtime User
Underscore characters are not permitted in domain names in accordance with RFC 1035, which only allows letters, digits and hyphens. As such, you cannot register a domain name with an underscore character.

that´s probably the issue. Use subdomainnames without underscore.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
It seems that underscores in the url are not handle well. In other applications, like postman, it is no problem to use underscores.
Please note that this has nothing to do with the library used (nor B4A). This is an issue with Android not accepting underscores in sub-domains. Blame it on the people not following standards (those that allowed underscores to be used). This may be fixed in future Android versions.

 
Upvote 0
Top