Description
Hey, any updates on this? I'm getting an _wait_for_handshake: failed
unfortunately, too. Please look at this:
Basic Infos
- This issue complies with the issue POLICY doc.
- I have read the documentation at readthedocs and the issue is not addressed there.
- I have tested that the issue is present in current master branch (aka latest git).
- I have searched the issue tracker for a similar issue.
- If there is a stack dump, I have decoded it.
- I have filled out all fields below.
Platform
- Hardware: ESP-12F
- Core Version: SDK:2.2.2-dev(38a443e)/Core:3.0.1=30001000/lwIP:STABLE-2_1_2_RELEASE/glue:1.2-48-g7421258/BearSSL:c0b69df
- Development Env: Platformio
- Operating System: Windows
Settings in IDE
- Module: Wemos D1 mini r2
- Flash Mode: qio
- Flash Size: 4MB
- lwip Variant: v2 Lower Memory
- Reset Method: ck
- Flash Frequency: [40Mhz]
- CPU Frequency: 80Mhz
- Upload Using: SERIAL
- Upload Speed: 115200
Problem Description
So I got problems to do the handshake with my tesla powerwall (solar battery storage system) which I'm doing a project with. The powerwall did an update and unfortunately as described I can not connect to it anymore. I'm getting the _wait_for_handshake: failed
error. However, if I try that request with curl on my PC it works just fine. Raspberry Pi also works. So problem has to have to do with the BearSSL-WifiClientSecure library.
Getting stuck here:
(In my project in lib/Powerwall/Powerwall.h:54
)
powerwall_ip = "192.168.178.38"
WiFiClientSecure httpsClient;
httpsClient.setInsecure();
httpsClient.setTimeout(10000);
int retry = 0;
while ((!httpsClient.connect(powerwall_ip, 443)) && (retry < 15)) {
delay(100);
Serial.print(".");
retry++;
}
if (retry >= 15) {
return ("CONN-FAIL");
}
Debug Messages
(DEV: doing GET-request to 192.168.178.38/api/system_status/soe)
:ref 1
BSSL:_connectSSL: start connection
_iobuf_in: 0x3fff1744
_iobuf_out: 0x3fffb2a4
_iobuf_in_size: 16709
_iobuf_out_size: 597
:wr 137 0
:wrc 137 137 0
:ack 137
:rcl pb=0 sz=-1
:abort
BSSL:_wait_for_handshake: failed
BSSL:Couldn't connect. Error = 'Unknown error code.'
.:ur 1
:dsrcv 0
:del
Debugging
I did some debugging with a friend and from the _wait_for_handshake
function (bool) in the WifiClientSecure-class we got to the _run_until
function and searched for the -1
. We found out the connection is crashing here:
if (!(_client->state() == ESTABLISHED) && !WiFiClient::available()) {
return (state & target) ? 0 : -1;
}
After this we just outputted the values of state
and target
via DEBUG_BSSL
and found out they were 4
and 8
. So they are not matching with the binary-and (&) so this has to be the problem.
These would be the two values:
/** \brief SSL engine state: engine may receive records from the peer. */
#define BR_SSL_RECVREC 0x0004
/** \brief SSL engine state: engine may accept application data to send. */
#define BR_SSL_SENDAPP 0x0008
Probably someone can help.