pubsubclient icon indicating copy to clipboard operation
pubsubclient copied to clipboard

publish() fails on ESP32

Open nixmeer opened this issue 2 years ago • 1 comments

Hello :)

I am trying to migrate my ESP8266 firmware to the ESP32 platform. However, publishing messages does return false when being called. Short topic and payload have been tested, and the client.connected() function is being checked before the attempt. In line 599 of PubSubClient.cpp, rc always returns 0. Taking a look at buf here reveals, that it starts with 0x10 0x1D and then the incomplete topic several times in a row (instead of Kueche/Schalter/1 it's Kueche/SchalteKueche/SchalteKueche/SchalteKueche/Schalte

something is really strange here. Has anybody seen anything like that before?

nixmeer avatar Mar 03 '23 20:03 nixmeer

The example mqtt_esp8266 publishes and subscribes with no problems on ESP32.I had to change include <WiFi.h> instead of <ESP8266WiFi.h>. And change "%ld" to "%d" in a sprintf. And with a few more changes, the example works on a Giga R1 WiFi.

esp32beans avatar Mar 27 '23 02:03 esp32beans