Open the-kenny opened 5 years ago
I hit a similar problem. Can not send the LWT when PubSubClient::connect() This problem only in version 2.7 The old version 2.6 work ok
Works as intended for me. With NodeMCU V3, PubSubClient 2.7 and Mosquitto 1.5.
Did anyone find a fix for this? I've got exactly the same problem as the above.
It does not work for me too. I can see that mosquitto is sending the lastWill message for example killing a MQTT.fx client. @djmaze can you please share your code, maybee we are doing a mistake in using it.
I have gone on in debugging using pubsubclient 2.7 and mosquitto 1.6.4 in mosquitto.conf I have added this configuration line: log_type all in the file /var/log/mosquitto/mosquitto.log we can see everything mosquitto is doing including pings.
with MQTT.fx when the connection is done I can see: New client connected from 172.20.10.2 as 52eb717743ac415ca688b83280dd5e9a (p2, c1, k30). 1565162993: Will message specified (6 bytes) (r0, q1). 1565162993: mqttfx
with esp8266: 1565163968: New client connected from 172.20.10.3 as ESP8266Client-1937 (p2, c1, k15). 1565163968: No will message specified.
I'm using the provided example for esp8266 with the connect line changed to: client.connect(clientId.c_str()), "", "", "endtopic", 1, false, "gone")
I hope this helps to locate the issue.
ok I found my issue, a leftover parenthesys... with this correct line the example works if (client.connect(clientId.c_str(), "", "", "endtopic", 1, true, "gone")) {
I'm very surprised that the previous code could compile!
I'm writing a fairly simple data logger using a Wemos D1 with an ESP8266 on top.
The following (shortened) code works just fine, but it fails to deliver properly set up the LWT message: If I disconnect the power supply and wait for it to time out on my mosquitto server, no message is published:
Debug log from mosquitto (showing connect):
Disconnect after timeout:
Any idea why this isn't working?