🎄⛄❄️🎁 It's beginning to look a lot like ADABOX-mas! The next ADABOX from Adafruit ships soon! Get yours now, or give as a gift! 🎄⛄❄️🎁
0

Connection issue on io.adafruit with MQTT and SSL
Moderators: adafruit_support_bill, adafruit

Forum rules
If you're posting code, please make sure your code does not include your Adafruit IO Active Key or WiFi network credentials.
Please be positive and constructive with your questions and comments.

Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Sun Sep 29, 2019 4:06 pm

Hello!

It seems like the MQTT connection with SSL can't be established for the past 3 weeks.

In more details, I'm using the "mqtt_esp8266" example provided in the Arduino software and when I use it as such (and update the wifi and Adafruit.io information) it works like a charm. When I try to use an SSL connection by changing:
Code: Select all | TOGGLE FULL SIZE
#define AIO_SERVERPORT  1883
WiFiClient client;
to
Code: Select all | TOGGLE FULL SIZE
#define AIO_SERVERPORT  8883
WiFiClientSecure client;


The MQTT connection fails to go through whereas it used to work very well. Has any update being performed on the io.adafruit servers?

Please let me know if there is anyhting I can do to help debug the situation.

Thanks!

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Fri Oct 04, 2019 2:33 pm

Has somebody encountered the same problem?
Is there any other parameter to change?

This situation really puzzles me as my code used to work.

Thank you in advance for any help.

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by brubell on Mon Oct 07, 2019 9:43 am

Hi pandiculation,

Are you using the following configuration with the Arduino IDE?

* ESP8266 Board Support Package 2.5.1
* Adafruit IO Arduino Library v3.2
* Adafruit MQTT Library v1.0 (or above)

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Mon Oct 07, 2019 4:08 pm

brubell wrote:Hi pandiculation,

Are you using the following configuration with the Arduino IDE?

* ESP8266 Board Support Package 2.5.1
* Adafruit IO Arduino Library v3.2
* Adafruit MQTT Library v1.0 (or above)


Hi brubell,

Thank you for helping.

I use:
Adafruit MQTT Library 1.0.3
Adafruit IO Arduino 3.2.2


Regarding the board, I use:
esp8266 by ESP8266 Community version 2.5.2

so I think I'm aligned with the versions you mentionned.

FYI, I use a Wemos D1 mini Lite board

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Tue Oct 15, 2019 10:39 am

Hi brubell,,

I take that if you use the "mqtt_esp8266" example out of the box and do the modifications I mentioned in my first post, you don't have any issue? Is that correct?

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by brubell on Wed Oct 16, 2019 4:16 pm

pandiculation wrote:Hi brubell,,

I take that if you use the "mqtt_esp8266" example out of the box and do the modifications I mentioned in my first post, you don't have any issue? Is that correct?


Yep, but I also do not own a Wemos d1. I test with a Feather Huzzah ESP8266.

Could you try this sketch? Does it work?

https://github.com/adafruit/Adafruit_MQ ... sp8266.ino

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Thu Oct 17, 2019 5:14 pm

Board selected in Arduino & code -> result
brubell wrote:Could you try this sketch? Does it work?

https://github.com/adafruit/Adafruit_MQ ... sp8266.ino


So I have done some tests and I came up with the following results (format is "Board selected in the Arduino software & code used -> result" - I hope that makes sense):
Wemos D1 mini Lite & mqtt_esp8266_debug -> Does not wok
Wemos D1 mini Lite & adafruitio_secure_esp8266 -> Error when compiling
LoLin (WEMOS) D1 mini Lite & mqtt_esp8266_debug -> Does not work
LoLin (WEMOS) D1 mini Lite & adafruitio_secure_esp8266 -> Works

So I have an option that works, I need to dig into the code now to understand the differences.

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by brubell on Mon Oct 21, 2019 10:40 am

So I have an option that works, I need to dig into the code now to understand the differences.


I'm interested in the outcome. If you change to port to 1883, does it work on the Wemos D1 mini Lite?

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Wed Oct 23, 2019 5:01 pm

If you change to port to 1883, does it work on the Wemos D1 mini Lite?

It does not work if I select Wemos D1 mini Lite in the Arduino software with the followings:
Code: Select all | TOGGLE FULL SIZE
#define AIO_SERVERPORT  1883
WiFiClientSecure client;

The trick was to use the following lines of code (at the correct places):
Code: Select all | TOGGLE FULL SIZE
#define AIO_SERVERPORT  8883
WiFiClientSecure client;
static const char *fingerprint PROGMEM = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
client.setFingerprint(fingerprint);

In this last instance, compiling with board Wemos D1 mini lite creates the following error:
Code: Select all | TOGGLE FULL SIZE
'class WiFiClientSecure' has no member named 'setFingerprint'
so I had to use the board LoLin (WEMOS) D1 mini Lite in the Arduino software and it works like a charm now!

Thanks for your help :)

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by brubell on Tue Oct 29, 2019 10:54 am

It's odd that WiFiClientSecure doesn't have a setFingerprint class...Could you link me to the board support package/Arduino IDE install instructions for the board?

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Tue Oct 29, 2019 2:51 pm

brubell wrote:It's odd that WiFiClientSecure doesn't have a setFingerprint class...Could you link me to the board support package/Arduino IDE install instructions for the board?

Does this link answer your question?
https://www.wemos.cc/en/latest/tutorials/d1/get_started_with_arduino_d1.html#installing-hardware-package

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by brubell on Tue Oct 29, 2019 2:56 pm

pandiculation wrote:
brubell wrote:It's odd that WiFiClientSecure doesn't have a setFingerprint class...Could you link me to the board support package/Arduino IDE install instructions for the board?

Does this link answer your question?
https://www.wemos.cc/en/latest/tutorials/d1/get_started_with_arduino_d1.html#installing-hardware-package

Yep, that error is odd - WiFiClientSecure does have a setFingerprint class:

https://github.com/esp8266/Arduino/blob ... L.cpp#L585

Could you try updating your ESP8266 board support package to the latest (v2.5.2) version, running your old (non-modified) code, and seeing if you get the same error?

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Tue Oct 29, 2019 5:33 pm

My code with these lines:
Code: Select all | TOGGLE FULL SIZE
#define AIO_SERVERPORT  1883
WiFiClientSecure client;
and the Wemos D1 mini Lite board selected gives the following errors in the Serial Monitor of the Arduino software (like before):
21:16:44.073 -> Connecting to MQTT... Connection failed
15:16:44.245 -> Retrying MQTT connection in 5 seconds...
15:16:49.481 -> Connection failed
15:16:49.481 -> Retrying MQTT connection in 5 seconds...
15:16:54.709 -> Connection failed
15:16:54.709 -> Retrying MQTT connection in 5 seconds...
15:17:02.426 ->
15:17:02.426 -> Soft WDT reset
15:17:02.426 ->
15:17:02.426 -> ctx: cont
15:17:02.426 -> sp: 3fff0210 end: 3fff0400 offset: 01b0


My code with these lines:
Code: Select all | TOGGLE FULL SIZE
#define AIO_SERVERPORT  8883
WiFiClientSecure client;
static const char *fingerprint PROGMEM = "77 00 54 2D DA E7 D8 03 27 31 23 99 EB 27 DB CB A5 4C 57 18";
client.setFingerprint(fingerprint);
and the Wemos D1 mini Lite board selected gives the following errors when compiling in the Arduino software (like before):
/var/folders/pv/2n12gcbs6bnbl_n37yby6dhw0000gn/T/arduino_modified_sketch_232193/mqtt_esp8266.ino: In function 'void loop()':
mqtt_esp8266:93:10: error: 'class WiFiClientSecure' has no member named 'setFingerprint'
client.setFingerprint(fingerprint);
^
Multiple libraries were found for "ESP8266WiFi.h"
Used: /Users/Deneb/Documents/Arduino/hardware/esp8266com/esp8266/libraries/ESP8266WiFi
Multiple libraries were found for "Adafruit_MQTT.h"
Used: /Users/Deneb/Documents/Arduino/libraries/Adafruit_MQTT_Library
exit status 1
'class WiFiClientSecure' has no member named 'setFingerprint'


All of these tests use the 2.5.2 library
ESP.jpg
ESP.jpg (21.03 KiB) Viewed 113 times

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by brubell on Wed Oct 30, 2019 9:35 am

I just tried compiling adafruitio_secure_esp8266 on my machine with the WeMos D1 Mini Lite selected as the board, did not run into the compilation error you did...
Code: Select all | TOGGLE FULL SIZE
[SNIP]
Using library ESP8266WiFi at version 1.0 in folder: /Users/brentrubell/Library/Arduino15/packages/esp8266/hardware/esp8266/2.5.2/libraries/ESP8266WiFi
Using library Adafruit_MQTT_Library at version 1.0.3 in folder: /Users/brentrubell/Documents/Arduino/libraries/Adafruit_MQTT_Library
/Users/brentrubell/Library/Arduino15/packages/esp8266/tools/xtensa-lx106-elf-gcc/2.5.0-3-20ed2b9/bin/xtensa-lx106-elf-size -A /var/folders/k6/g066g1tn567fn8mj2p42x4240000gn/T/arduino_build_351330/adafruitio_secure_esp8266.ino.elf
Sketch uses 385760 bytes (37%) of program storage space. Maximum is 1023984 bytes.
Global variables use 29100 bytes (35%) of dynamic memory, leaving 52820 bytes for local variables. Maximum is 81920 bytes.


Two things stick out to me, though:

Multiple libraries were found for "ESP8266WiFi.h"
and
Multiple libraries were found for "Adafruit_MQTT.h"

This might be causing the error. Close the Arduino IDE. Then, navigate to /Users/Deneb/Documents/Arduino/hardware/ and delete the esp8266com folder(s, there may be more than one). Then navigate to /Users/Deneb/Documents/Arduino/libraries/ and delete all instances of Adafruit_MQTT_Library.

Open Arduino and install the ESP8266 board support package again, along with Adafruit MQTT.

brubell
 
Posts: 609
Joined: Fri Jul 17, 2015 10:33 pm

Re: Connection issue on io.adafruit with MQTT and SSL

by pandiculation on Mon Nov 04, 2019 6:06 pm

So, I followed your instructions and the Wemos D1 mini Lite board has now disappeared. I only have LoLin (WEMOS) D1 mini Lite. I guess it's alright!

pandiculation
 
Posts: 18
Joined: Wed Apr 04, 2018 7:20 pm

Please be positive and constructive with your questions and comments.