issue with io.popen and curl on localhost

Moderator: leecollings

Post Reply
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

issue with io.popen and curl on localhost

Post 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)
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
jmleglise
Posts: 192
Joined: Monday 12 January 2015 23:27
Target OS: Raspberry Pi / ODroid
Domoticz version: 2022.1
Location: FRANCE
Contact:

Re: issue with io.popen and curl on localhost

Post 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 ?!?
My script : https://github.com/jmleglise
RFXTRX433E: Blind Somfy RTS, Portal Somfy Evolvia, chacon IO, Oregon, PIR sensor PT2262
My Last project : Location de vacances a Ouistreham vue mer
KMTronic USB relay
Chinese Z-WAVE: Neo CoolCam
ridderr
Posts: 2
Joined: Tuesday 21 June 2016 22:59
Target OS: -
Domoticz version:
Contact:

Re: issue with io.popen and curl on localhost

Post 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.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest