09.05.2018, 06:20
Hi,
I use this code as a resident script that runs every 30 second. It works great, but it is loosing connection after 4-4.5 hour.
I then have to disable --> enable script again to get it started. I have tried both line 12 and 15 commented out with no difference.
This script is running fine on 2 other LM`s so I dont`t think the broker is the problem.
Have anyone had the same problem, or any idea of what the problem can be ?
I use this code as a resident script that runs every 30 second. It works great, but it is loosing connection after 4-4.5 hour.
I then have to disable --> enable script again to get it started. I have tried both line 12 and 15 commented out with no difference.
This script is running fine on 2 other LM`s so I dont`t think the broker is the problem.
Code:
mqtt = require("mosquitto")
client = mqtt.new()
--------------------------------------------------
value = math.random(0, 1000)
--------------------------------------------------
client.ON_CONNECT = function()
client:publish("test/1/LMdata", '{"site": "office", "heartbeat":"'..value..'"}')
local qos = 1
local retain = true
--local mid = client:publish("test/1/LMdata", '{"site": "office", "heartbeat":"'..value..'"}', qos, retain)
end
client.ON_PUBLISH = function()
client:disconnect()
end
broker = '10.10.10.18'
client:login_set("user","passwd")
client:connect(broker)
client:loop_forever()
Have anyone had the same problem, or any idea of what the problem can be ?