-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ESP32 and W5500 based Secure Ethernet for HTTPS or MQTTS? #44
Comments
HI @winnergeorge, I don't have a W5500 here so I won't be able to help you directly: try these steps - Based on your description, it seems that you're trying to connect to a MQTT broker using an Ethernet connection on an ESP32 with the W5500 Ethernet module and secured using the SSLClient library, but your messages are not being published. Here are a few steps you can take to troubleshoot this issue: Check Your Connection: First, ensure that your device is correctly connected to the internet through the W5500 Ethernet module. You can test this by making a simple HTTP request or pinging a server. If you're unable to connect to the internet, you should double-check your wiring, power supply, and internet connection. Verify SSL/TLS Connection: If your device is able to connect to the internet, the next step is to ensure that your SSL/TLS connection is correctly set up. SSLClient library needs a few parameters to make a connection, such as the certificate of the MQTT server. If these parameters aren't correctly set, you won't be able to establish a connection. MQTT Connection: Once you've verified your SSL/TLS connection, you should check if you're able to establish a connection to your MQTT broker. You can verify this by checking the return code of the mqttEthClient.connect() function. If it returns false, then you're unable to connect to the MQTT broker. Check QoS and Retain Flag: Make sure you're setting the correct Quality of Service (QoS) level and retain flag when publishing messages. If you're setting a QoS level higher than the broker supports or the retain flag incorrectly, your messages might not be published. Debugging: The PubSubClient library provides a state() function that returns the current state of the client. You can use this to print the state of your client and potentially figure out what's going wrong. The SSLClient also provides various debug options that you can enable to see more detailed error messages. Lastly, if all these steps fail, you might want to try using a different MQTT library to see if the issue lies within the PubSubClient library. There are many other libraries available, like the Adafruit_MQTT library or the AsyncMqttClient library, both of which also support secure MQTT connections. If this works then please post the solution (and thanks GPT4!) and if it doesn't then you will have to supply a link to code to assist in making a determination. Good luck... |
Hi @RobertByrnes . I have two different Mosquitto brokers on separate AWS clients. One is plain MQTT and the other is MQTT with SSL. Arduino Code: #include <SPI.h> // MQTT Broker details #define ETHERNET_RST_PIN 25 // Ethernet uses default SPI: MOSI -> 23, MISO -> 19, SCLK -> 18, CS -> 5 EthernetClient LANClient; StaticJsonDocument<2048> JSONencoder; void setup() { Serial.begin(115200); //Default Serial Monitor checkEthernetConnection(); } void loop() { JSONencoder["Data"] = "Hello from W5500"; if (mqttEthClient.connect(mqttClientId)) {
} void checkEthernetConnection() { |
Your network setup seems fine. This is evidenced by the ESP32 with W5500 being able to connect to a Non-Secure MQTT broker. Certificate Mismatch ??? SSL Client Configuration: SSL/TLS requires a fair bit of memory, especially when handling certificates. The ESP32 should have enough memory, but it's always worth ensuring that you aren't running into any memory allocation issues. If using AWS, ensure that your Security Groups or Network ACLs allow for incoming connections on port 8883 (MQTT SSL port) from your device's IP. MQTT Credentials:
Persistent MQTT Session: Broker Logs: |
I tried with W5500 connected with ESP32 and PubSubClient library for Secured MQTT
EthernetClient LANClient;
SSLClient secureClientEth(&LANClient);
PubSubClient mqttEthClient(secureClientEth);
EthernetLarge library is used. The code does get compiled however messages dont get published to the Broker. Anyone tried this for Ethernet and got success?
The text was updated successfully, but these errors were encountered: