Skip to content
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

Properly Setting up Last Will Message #15

Open
vgooljar opened this issue Oct 11, 2018 · 3 comments
Open

Properly Setting up Last Will Message #15

vgooljar opened this issue Oct 11, 2018 · 3 comments

Comments

@vgooljar
Copy link

In example:
https://github.com/tuanpmt/ESP8266MQTTClient/blob/master/examples/MQTTClient/MQTTClient.ino#L32

The last will message is set up without referring to the keepalive argument as specified in:
https://github.com/tuanpmt/ESP8266MQTTClient/blob/master/src/ESP8266MQTTClient.cpp#L72

The example should probably be changed to include the keepalive (& cleansession), so predictable behaviour can be expected with the last will messages. Otherwise, the last will msg seems to be sent and printed in the topic before any other messages, whenever the connection is created.

@vvangelov
Copy link

Hi, I am setting up method with keepalive and cleansession. When I turn off my device I still don't get any msg from lwt.
This is my "begin" configuration, but it doesn't work.
mqtt.begin(mqtt_broker_server, {.lwtTopic = status_topic, .lwtMsg = "offline", .lwtQos = 0, .lwtRetain = 1}, 600, false);
Is it something in common that keepalive here is specified in milliseconds, and default keepalive in mosquitto broker is in seconds. Or I am wrong?
If someone can help, I will be happy.

@vgooljar
Copy link
Author

vgooljar commented Apr 2, 2019

Hi, I am setting up method with keepalive and cleansession. When I turn off my device I still don't get any msg from lwt.
This is my "begin" configuration, but it doesn't work.
mqtt.begin(mqtt_broker_server, {.lwtTopic = status_topic, .lwtMsg = "offline", .lwtQos = 0, .lwtRetain = 1}, 600, false);
Is it something in common that keepalive here is specified in milliseconds, and default keepalive in mosquitto broker is in seconds. Or I am wrong?
If someone can help, I will be happy.

I strongly recommend checking out PubSubClient
It's much more mature and behaves more predictably for MQTT stuff. If your payload sizes are greater than 128 characters, you'll have to edit this in the header files

@vvangelov
Copy link

I changed PubSubClient lib with this one, because it support all qos levels and wifisecure. I am still searching for the perfect one.
I think I found solution for my problem. I replace this line in ESP8266MQTTClient.cpp
_connect_info.keepalive = _keepalive;
with this one
_connect_info.keepalive = _keepalive / 1000;
I am using mosquitto for broker and i just converting the milliseconds to seconds in connect data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants