ESP8266 WiFiClientSecure Exception 9

  arduino-esp8266, c++, esp8266, esp8266wifi, wifi

I have a few problems trying to connect my ESP8266 to my WebServer.
I want to connect to a Webserver and then send Information via the REST-API to the Server.

Unfortually my Program Crashes when connecting to the Server.

This is my code:

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>

#ifndef STASSID
#define STASSID "SSID" //SSID
#define STAPSK  NULL //Password
#endif

const char* ssid = STASSID;
const char* password = STAPSK;

const char* host = "IP-Adress"; //Load Balancer IP
const uint16_t httpsPort = 443; //Load Balancer Port

// Use web browser to view and copy SHA1 fingerprint of the certificate
const char fingerprint[] PROGMEM = "FI NG ER PR IN T0";

void setup() {
  Serial.begin(115200);
  
  Serial.println("[INFO]ttStarting GPS Service");
  Serial.printf("[INFO] LAN:tConnecting to WiFi '%s'", ssid);
  
  WiFi.mode(WIFI_STA); //Setting WiFi Client Mode
  WiFi.begin(ssid, password); //Connecting to WiFi
  
  while (WiFi.status() != WL_CONNECTED) {
    delay(250);  Serial.print("."); //Waiting for WiFi Connection
  }
  Serial.print("n");
  
  Serial.printf("[INFO] LAN:tSuccessfully Connected to WiFi '%s'n", ssid);
  Serial.print("[INFO] LAN:tLocal IP-Address '");
  Serial.print(WiFi.localIP());
  Serial.print("'n");
  
  Serial.printf("[INFO] WAN:tConnecting to %s:%dn" ,host, httpsPort);
  
  WiFiClientSecure client; // Use WiFiClientSecure class to create TLS connection

  Serial.printf("[INFO] WAN:tUsing fingerprint '%s'n", fingerprint);
  
  client.setFingerprint(fingerprint); //Set Fingerprint for WiFiClientSecure

  if (client.connect(host, httpsPort)) { //Here my Programm is Crashing
    Serial.printf("[INFO] WAN:tSuccessfully Connected to WAN-IP '%s'n", host);  
  } else {
    Serial.println("[ERROR] WAN:tConnection failed!");
    return;
  }
  Serial.println("[INFO] WAN:tClosing connection");
}

void loop() {
}

The Programm Crashes at this Point if (client.connect(host, httpsPort)) {

This is the Output:

[INFO] Starting GPS Service
[INFO] LAN: Connecting to WiFi 'SSID'.
[INFO] LAN: Successfully Connected to WiFi 'SSID'
[INFO] LAN: Local IP address '192.168.178.*'
[INFO] WAN: Connecting to Server-Adress
[INFO] WAN: Using fingerprint 'FI NG ER PR IN T0'

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

Exception (9):
epc1=0x40207874 epc2=0x00000000 epc3=0x00000000 excvaddr=0xfeefeffe depc=0x00000000

>>>stack>>>
...
<<<stack<<<

--------------- CUT HERE FOR EXCEPTION DECODER ---------------

When I decode the Stack i get the Following:

Decoding 12 results
0x40203aab: BearSSL::WiFiClientSecure::_connectSSL(char const*) at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3librariesESP8266WiFisrc/WiFiClientSecureBearSSL.cpp line 1093
0x40205878: esp_yield at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3coresesp8266/core_esp8266_main.cpp line 119
0x40205e72: __delay at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3coresesp8266/core_esp8266_wiring.cpp line 54
0x402026c0: WiFiClient::connect(IPAddress, unsigned short) at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3librariesESP8266WiFisrc/include/ClientContext.h line 144
: (inlined by) WiFiClient::connect(IPAddress, unsigned short) at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3librariesESP8266WiFisrc/WiFiClient.cpp line 170
0x40203c81: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3librariesESP8266WiFisrc/WiFiClientSecureBearSSL.cpp line 229
0x40207e20: precache at ?? line ?
0x40207e20: precache at ?? line ?
0x40250e56: sleep_reset_analog_rtcreg_8266 at ?? line ?
0x40201138: setup at C:UsersUsernameDesktopBeispieleWiFi/WiFi.ino line 58
0x40207cc0: precache at ?? line ?
0x40205988: loop_wrapper() at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3coresesp8266/core_esp8266_main.cpp line 194
0x40100bd5: cont_wrapper at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp8266.7.3coresesp8266/cont.S line 81 

Anyone got an Idea how to fix this?
Thanks in advance,
Patrick

Source: Windows Questions C++

LEAVE A COMMENT