Android Question Problem with HttpUtils2Service.bas and HttpJob.bas

Jeff Garland

Member
Licensed User
Longtime User
I'm trying to do a simple get from my phone (B4A) to a server on my ESP32. I do not want to deal with certs right now so I have downloaded and installed the two code files HttpUtils2Service.bas and HttpJob.bas. I modified the hc line to be "hc.InitializeAcceptAll("hc")".

When I make the calls I get the following error that I can't find any info on. Any ideas?

"ResponseError. Reason: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x76bc6a2608: I/O error during system call, Software caused connection abort, Response: "

Here is my code that runs when the forward button on my B4A is clicked::

Sub buttonForward_Click
Dim url As String
url = "https://192.168.4.1/forward"

Dim j As HttpJob
j.Initialize("", Me)
j.Download(url)
Wait For (j) JobDone(j As HttpJob)
If j.Success Then
Log(j.GetString)
End If
j.Release
End Sub


The webserver on my esp32 is on 443 and I can hit it by typing that url command in from a browser on my phone or PC.
 

drgottjr

Expert
Licensed User
Longtime User
are client and server using the same tls level?
 
Upvote 0

Jeff Garland

Member
Licensed User
Longtime User
I can hit the server from my phone browser just fine so if it is off, it is on the B4A settings side since I am running on the same phone. I'm not sure how to check that.
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
your server (at least) is configured somehow. probably a .conf file or some such. see which tls level(s) is supports and/or defaults to. i'm pretty sure this error has come up before with okhttputils. try the little search box up at the top of this page. whether you can change okhttputils' tls, i forget. that's why i suggest seeing if you can see what's going on server side. chrome and okhttputils are not the same thing.

i would think if you can successfully connect with some https server in the wild using okhttputils, then the issue is not with okhttputils, right? try https://www.google.com. i connect with https servers all the time using okhttputils... i just connected to https://www.google.com with acceptall on.

let me amend that: i've used the okhttputils source modules with the acceptall setting without issue. the handshake issue comes later.
 
Last edited:
Upvote 0

Jeff Garland

Member
Licensed User
Longtime User
your server (at least) is configured somehow. probably a .conf file or some such. see which tls level(s) is supports and/or defaults to. i'm pretty sure this error has come up before with okhttputils. try the little search box up at the top of this page. whether you can change okhttputils' tls, i forget. that's why i suggest seeing if you can see what's going on server side. chrome and okhttputils are not the same thing.

i would think if you can successfully connect with some https server in the wild using okhttputils, then the issue is not with okhttputils, right? try https://www.google.com. i connect with https servers all the time using okhttputils... i just connected to https://www.google.com with acceptall on.

let me amend that: i've used the okhttputils source modules with the acceptall setting without issue. the handshake issue comes later.

I cannot connect to anything with okhttputils. It throws the message I listed in my initial post. I can connect to my server from my browser on my phone and PC. If there is a tls mismatch it is with b4a but I do not think that is the issue.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

Jeff Garland

Member
Licensed User
Longtime User
What version of B4A? If you are using the latest, don't use the class files unless you are making modifications beyond InitializeAcceptAll. See https://www.b4x.com/android/forum/threads/b4x-okhttputils2-ihttputils2-and-accept-all-option.110673/

ver 9.90. Yes I am doing an InitializeAcceptAll as certs on the esp32 are iffy in my experience. This thing is only running on my backyard so I don't need certs. Yes I have seen that page.

Does that error look familiar? "ResponseError. Reason: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x76bc6a2608: I/O error during system call, Software caused connection abort, Response: "
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. Please use [code]code here...[/code] tags when posting code.
2. As written above you can keep using the library and enable "initialize accept all".
3. InitializeAcceptAll helps with one specific case - the certificate authority it unknown. It will not help with incompatible cipher protocols or any other SSL misconfigurations.
 
Upvote 0

Jeff Garland

Member
Licensed User
Longtime User
It is already enabled (InitializeAcceptAll) and I get the error I have posted: "ResponseError. Reason: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x76bc6a2608: I/O error during system call, Software caused connection abort, Response: "

I can hit the server from my phone browser by typing that same url command into the command line but I get the error when tying to hit it from B4A using okhttputils.

I have already started rewriting using bluetooth (The controller has wifi and BT) since no one seems to know what that error means.
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
What does this URL do? If you just connect to https://192.168.4.1, what happens?
"ResponseError. Reason: javax.net.ssl.SSLHandshakeException: SSL handshake aborted: ssl=0x76bc6a2608: I/O error during system call, Software caused connection abort, Response: "
Is that the only error message? Nothing is shown in the response?
If j.Success Then
Log(j.GetString)
End If
How about
B4X:
If j.Success Then
Log(j.GetString)
Else
Log(j.ErrorMessage)
End If
To see what HttpJob's error message is?
 
Upvote 0

Jeff Garland

Member
Licensed User
Longtime User
What does this URL do? If you just connect to https://192.168.4.1, what happens?

Is that the only error message? Nothing is shown in the response?

How about
B4X:
If j.Success Then
Log(j.GetString)
Else
Log(j.ErrorMessage)
End If
To see what HttpJob's error message is?

Yes that's the only error message you get whether you tell it to print out the error message or not. Nothing in the response.

So this thing is a b4A app on my phone talking to an ESP32 that is controlling a startracker I built. I have calls into the server stood up by the esp32 to put it in various modes like forward, reverse, stop and various speeds like Sidereal, Lunar, Solar, KingDay or for repositioning rate. The B4A app handles more details like it allows me to set imaging times of a few seconds up to an hour. Alignment is not good enough to go beyond 30 minutes typically and that is OK. One of my calls is to set it in forward mode. When I type in and send ""https://192.168.4.1/forward" from the browser on my phone, mytracker goes into forward mode. When I send "https://192.168.4.1/reverse" it goes reverse etc. It works fine from the browser and the tracker does exactly what I want so I know my esp32 code and the server is good. B4A just won't connect over wifi.

No worries, I hoped somebody knew what that error meant. I have never used wifi like this for control since most of my controllers have bluetooth but not wifi. Now I am switching back to bluetooth since I have both.
 
Upvote 0
Top