mathworks / thingspeak-arduino

ThingSpeak Communication Library for Arduino, ESP8266 and ESP32
https://thingspeak.com
431 stars 231 forks source link

Library check for WifiSSLClient causes SSL connection to fail #79

Closed fengrun85 closed 3 years ago

fengrun85 commented 3 years ago

Using Arduino MKR Wifi 1010

Had a sketch pre-2.0 working until I upgraded to 2.0.

I added #define TS_ENABLE_SSL and included WifiSSLClient.h

Error in Serial Monitor was -301

Turned on debug and found that the connection was back to port 80 instead of 443

Commented out two lines in the Thingspeak.h file and it worked.

        #if defined(TS_ENABLE_SSL)
            **//#if defined(WIFISSLCLIENT_H) || defined(wificlientbearssl_h) || defined(WiFiClientSecure_h)

            //#endif**
        #endif

The check for the WifiSSLClient.h was not working even if I included the library in my sketch.

By default WifiNina library already includes WifiSSLClient in it. In fact, when I first included WifiSSLClient.h, it threw an compile error because it conflicts with Wifi101's WifiSSLClient. I had to delete my Wifi101 to remove this conflict.

Suggest you find a better way to check for Wifi SSL Client

Tommy-01 commented 3 years ago

I commented this lines out, like suggested, but i still get the same -301 Error. I'm using a ESP32.

Is there a way to get this thing working?

I solved this by addin client.setInsecure(); Into the sketch.

v-c commented 3 years ago

The order of the #define and #include statement matters.

define TS_ENABLE_SSL

// ... the above line must be before the following 2 includes.

include

// The #include must be before #include of "ThingSpeak.h"

include "ThingSpeak.h"

Take a look at this example, https://github.com/mathworks/thingspeak-arduino/tree/master/examples/ArduinoMKR1000/WriteSingleFieldSecure