knolleary / pubsubclient

A client library for the Arduino Ethernet Shield that provides support for MQTT.
http://pubsubclient.knolleary.net/
MIT License
3.78k stars 1.46k forks source link

publish() fails on ESP32 #1003

Open nixmeer opened 1 year ago

nixmeer commented 1 year ago

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?

esp32beans commented 1 year ago

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