Open kamrulroky opened 7 years ago
Hey! any update here? I am having the same issue. Moreover even after defining the MQTT_KEEPALIVE 60. I have sniffed the packets using Wire shark , it sends the keep alive with default value of 15. I don't know why?
How have you changed MQTT_KEEPALIVE? You'll need to change it in the PubSubClient.h file, not in your sketch.
Thanks
Hey ! If I set the keep alive=0 then the connection establishes at first and the client subscribes to the broker. But the callback doesn't work. anything broker tries to publish onto that subscribed topic by the client does not get received. Simply, the callback doesn't work if keep-alive time=0. Note: Since I have set the keep alive time to 0 then to prevent client to send aggressive ping requests, I have disabled ping by commenting out all the mqtt.loop() function in my code.
Should I do that or increase interval of ping request by client and ensure it sends pings?
If you never call mqtt.loop()
then you are never allowing the client to check if there are incoming messages to read from the network, so the callback will never be called.
You should set the keepalive to something > 0 and ensure you call loop
if you want the client to receive messages.
@knolleary Hi knolleary. I have same problem about time-out connection between SIM800A to cloudmqtt, I use stm32f407 to send AT command to sim800. I try change KEEP-ALIVE value in packet connect and after this interval, server disconnect to sim800a. So, I want SIM800 keep connection continuously to server to subscribe message from server any time. How can I solve this problem? I think I need send PINGREG packet to server, but I don't know how to send PINGREG packet with AT command.
Hello, I am trying to publish sensor data to MQTT using SIM800l , I have used https://github.com/vshymanskyy/TinyGSM library to connect with cloudmqtt.this library use pubsubclient for MQTT client. it works fine with mosquitto broker setup on windows. But with authentication credentials from cloudmqtt , sim800l could not connect to the server.using client.state() it show -4 which is keep alive timeout problem. I have changed keep alive time from 15 to 60 as this #223 issue mentioned. here is the code
please help me with this problem, i am new and trying to learn