Hello all,
when I run secure MQTT on an ESP8266 HTTPS doesn’t respond to any request. the problem has the following symptoms:
-
when running HTTPS without MQTT or when closing the MQTT connection using client.stop(); https works fine.
-
when connecting to non secure MQTT (port 1883) HTTPS works fine.
-
while connected to secure MQTT (port 8883) HTTPS doesn’t answer any requests
here is my code:
#include <ESP8266WiFi.h>
#include <rgb_lcd.h> // include the grove RGB LCD library
#include <ESP8266WebServerSecure.h>
#include <ESP8266mDNS.h>
#include "Adafruit_MQTT.h"
#include "Adafruit_MQTT_Client.h"
...
...
BearSSL::WiFiClientSecure client;
BearSSL::ESP8266WebServerSecure server(443);
Adafruit_MQTT_Client MQTT(&client, ADASERVER, ADAPORT, ADAUSERNAME, ADAKEY);
...
...
void setup() {
...
...
client.setFingerprint( fingerprint );
MQTT.subscribe( &MQTT_FEED);
server.getServer().setRSACert( new BearSSL::X509List( cert ), new BearSSL::PrivateKey( key ) );
server.on("/", respond );
server.onNotFound( respond );
server.begin();
mqttConnect();
}
void loop() {
// static Variables to store the time of each task's last call
static unsigned long CFF_LC = 0,
LCD_LC = 0, // time of lcdUpdate last call
SHR_LC = 0, // time of shareReadings last call
TASK4LC = 0;
static unsigned long currentMillis; // store current time in milli seconds
static unsigned long currentSeconds; // store current time in seconds
currentMillis = millis();
currentSeconds = currentMillis / 1000 + 1; // added + 1 so currentSeconds is never 0, to avoid division by 0
MDNS.update();
//###########################################
server.handleClient(); ///###########//// doesn't work unless I do clinet.stop();
//###########################################
if ( currentMillis - CFF_LC >= CFF_INT ) {
CFF_LC = currentMillis ;
countPress();
}
// execute lcdUpdate when the time passed is more than the countFootfall interval
if ( currentMillis - LCD_LC >= LCD_INT ) {
LCD_LC = currentMillis ; // lcdUpdate last call = now
float currentMinutes = currentSeconds / 60.0;
averagePress = totalPress / currentMinutes;
mqttSubscribeToFeeds();
lcdUpdate();
}
if ( currentMillis - SHR_LC >= SHR_INT ) {
SHR_LC = currentMillis;
mqttConnect();
shareReadings();
}
Please any ideas on why this is happening and how to solve the problem ?