Page 1 of 1

issue with io.popen and curl on localhost

Posted: Thursday 31 December 2015 12:48
by jmleglise
I'm loosing my mind...

This lua script doesn't work and return a log error "running for more than 10 seconds":

Code: Select all

local handle=assert(io.popen('curl.exe 127.0.0.1:8081'))
local response = handle:read('*all')
handle:close()
For debugging, I ve tried the following :

This shell command works fine (in a terminal) and complete in about 5 sec:

Code: Select all

curl.exe 127.0.0.1:8081
This same lua script works fine too :

Code: Select all

local handle=assert(io.popen('curl.exe www.google.fr'))
local response = handle:read('*all')
handle:close()
I have deactivated my Website Protection in Domoticz settings.

What am I missing ?

My aim is to read the log history of a temp sensor and test if temp goes under 0°C in the past few hours . (http://127.0.0.1:8081/json.htm?type=gra ... &range=day)

Re: issue with io.popen and curl on localhost

Posted: Thursday 31 December 2015 18:55
by jmleglise
It's crazy, I continue my investigation ...

This first script doesn't work. ("running for more than 10sec ...")

script_device_testjson.lua

Code: Select all

commandArray={}

if (devicechanged['ManualLaunchScript'] == 'On' and otherdevices['ManualLaunchScript'] == 'On') then
	commandArray['ManualLaunchScript']='Off'
	
	local handle=assert(io.popen('curl.exe 127.0.0.1:8081'))
	local response = handle:read('*all')
	handle:close()
	print(response)
end
	
return commandArray
When the same in a time script works !!! I have an output in log every minute.

script_time_testjson.lua

Code: Select all

commandArray={}

local handle=assert(io.popen('curl.exe 127.0.0.1:8081'))
local response = handle:read('*all')
handle:close()
print(response)

return commandArray

What's going on ?!?

Re: issue with io.popen and curl on localhost

Posted: Tuesday 21 June 2016 23:04
by ridderr
I had the same issue today and found that when I switch my lights off/on from my mobile it all works fine. When I switch lights via the browser I'm also getting an 10 seconds error. Will do some more investigation and the i probably will raise and bug.