I am trying to connect to a free private HiveMQ MQTT-Broker with ESP32 + SIM800L (GitHub - Xinyuan-LilyGO/LilyGo-T-Call-SIM800) using TinyGSM and PubSubClient library.
I am getting
### Unhandled: +CME ERROR: operation not allowed
and a MQTT connection state of “-2” which means “the network connection failed” according to Arduino Client for MQTT.
I read about “SNI” which has to be active, but I can’t find any way to activate it with the TinyGSM library and I don’t know if it even supports “SNI”.
However, I am able to connect to the free public HiveMQ MQTT-Broker without activating “SNI”.
My Question: Is there any example code for my constellation (private HiveMQ + SIM800L)?
I am not really sure how to setup the layers but the following setup got me a connection to the free broker:
TinyGsm modem(SerialAT);
TinyGsmClientSecure gsmClient(modem);
SSLClient sslClient(&GSMclient);
PubSubClient mqtt(SSLclient);
Before calling the reconnect function, I added the certificate (but the connection also works with this line commented out):
sslClient.setCACert(root_ca);
Hello @niclas_r ,
Welcome to the HiveMQ community!
To confirm, when you specify a free private HiveMQ MQTT broker, do you mean the HiveMQ Free Cloud version, or the Community Edition broker?
As for TLS-SNI, that is correct - the public broker does not utilize the same TLS protocol as the Private Cloud Broker implementations, and is not subject to the same connection methods. SNI is a sub-set of TLS protocol, and would need to be enabled. This may need to be clarified with the manufacturer, to ensure that the SIM800L model supports SNI as well.
If you are able to verify that SNI is supported, and continue to have trouble, please also share the full error, as well as the full connection code used, so we can investigate further.
As an additional note, we do have a guide for an ESP8266 available within our Cloud Broker page. This example uses the PubSub library as well, and will likely have useful code snippets! (From your https://console.hivemq.cloud/ page, navigate to ‘manage cluster’, then ‘getting started’ at the top, and ‘arduino’ from the guide list).
Let us know if you have any further questions, and welcome, again, to the community!
Best,
Aaron from HiveMQ Team
Hi @AaronTLFranz , thanks for the quick reply. With free private HiveMQ Broker, I mean the Free Cloud version (xxx.s2.eu.hivemq.cloud). With free public HiveMQ Broker I mean broker.hivemq.com.
I already read the Arduino Guide, but that uses the ESP8266WiFi Library and not the TinyGSM library, so that’s a bit different in case of certificates as far as I know.
I assume that the SNI thing is causing problems connecting to the Broker, so I’ll check that.
Thanks again!
Hello, @niclas_r
Sounds good - thank you for the follow up and clarification! Let us know if there is anything more we can assist with in the meantime.
Best,
Aaron from HiveMQ Team