Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
270 views
in Technique[技术] by (71.8m points)

c++ - ESP8266 WiFiClientSecure Exception 9

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]Starting GPS Service");
  Serial.printf("[INFO] LAN:Connecting 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("
");
  
  Serial.printf("[INFO] LAN:Successfully Connected to WiFi '%s'
", ssid);
  Serial.print("[INFO] LAN:Local IP-Address '");
  Serial.print(WiFi.localIP());
  Serial.print("'
");
  
  Serial.printf("[INFO] WAN:Connecting to %s:%d
" ,host, httpsPort);
  
  WiFiClientSecure client; // Use WiFiClientSecure class to create TLS connection

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

  if (client.connect(host, httpsPort)) { //Here my Programm is Crashing
    Serial.printf("[INFO] WAN:Successfully Connected to WAN-IP '%s'
", host);  
  } else {
    Serial.println("[ERROR] WAN:Connection failed!");
    return;
  }
  Serial.println("[INFO] WAN:Closing 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:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.7.3librariesESP8266WiFisrc/WiFiClientSecureBearSSL.cpp line 1093
0x40205878: esp_yield at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.7.3coresesp8266/core_esp8266_main.cpp line 119
0x40205e72: __delay at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.7.3coresesp8266/core_esp8266_wiring.cpp line 54
0x402026c0: WiFiClient::connect(IPAddress, unsigned short) at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.7.3librariesESP8266WiFisrc/include/ClientContext.h line 144
: (inlined by) WiFiClient::connect(IPAddress, unsigned short) at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.7.3librariesESP8266WiFisrc/WiFiClient.cpp line 170
0x40203c81: BearSSL::WiFiClientSecure::connect(char const*, unsigned short) at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.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:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.7.3coresesp8266/core_esp8266_main.cpp line 194
0x40100bd5: cont_wrapper at C:UsersUsernameDesktopArduinoPortableApparduinoportablepackagesesp8266hardwareesp82662.7.3coresesp8266/cont.S line 81 

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

question from:https://stackoverflow.com/questions/65939145/esp8266-wificlientsecure-exception-9

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I was able to fix this Problem, a full reinstalled of the Arduino Portable IDE worked for me.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...