Page 1 of 1

Lua script hangs waiting for Curl / help needed

Posted: Monday 17 December 2018 16:47
by SiggeStardust
Hi

I have a couple of LUA scripts that sometimes dont get respons and then just waiting and hangs my system.
I want to have a set timeout that if i dont get respons within X seconds then terminate the script optional terminate and give a pushnotice.
below is my Script anyone that can assist me ?
/Peter



local switch_door = 'EntreDörr'

commandArray = {}

json = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()

local config=assert(io.popen('curl "http://192.168.x.x:8180/api/states/lock.entren"'))


local s = config:read('*all')
config:close()
local JsonData = json:decode(s)


if JsonData.state == "locked" then
commandArray[switch_door]='On'
else
commandArray[switch_door]='Off'
end

return commandArray

Re: Lua script hangs waiting for Curl / help needed

Posted: Tuesday 18 December 2018 0:18
by waaren
SiggeStardust wrote: Monday 17 December 2018 16:47 I have a couple of LUA scripts that sometimes dont get respons and then just waiting and hangs my system.
Have a look at dzVents async HTTP It's designed to overcome this type of delays and hanging systems.