Page 1 of 1
Can't open HTTPS URL:s using LUA script
Posted: Monday 28 November 2016 16:24
by BakSeeDaa
Version: 3.5877
Platform: Raspberry Pi 3B
Description:Error opening https URL:s when MQTT HW Device is removed
Hi there. I needed to clean up my installation a bit.
I installed the latest Raspbian Jessie Lite SD card image today followed by installing Domoticz. After that I restored the Domoticz database from a backup.
I have one issue that I can not solve. I had been experimenting with MQTT before and I had a MQTT hardware (MQTT Client Gateway with LAN Inteface) defined. After doing the re-installation I get error messages in the log:
Code: Select all
Error: MQTT: Failed to start, return code: 14 (Check IP/Port)
So, to get rid of that problem I disabled the MQTT hardware and the error messages disappeared. I don't need MQTT. However when I disable (or remove ) the MQTT Hardware I get a new problem.
Using LUA,
commandArray['OpenURL']='http://www.gp.se' works fine but
commandArray['OpenURL']='https://www.gp.se' fails with the error: Error: Error opening url:
https://www.gp.se
I will be so happy for any kind help to solve this issue. Thanks!
Re: Error opening https URL:s when MQTT HW Device is removed
Posted: Monday 28 November 2016 17:32
by gizmocuz
Thats correct, with the new install method, you need to install additional software yourself, like the mosquito mqtt broker
this might work:
apt-get install mosquitto
Re: Can't open HTTPS URL:s using LUA script
Posted: Monday 28 November 2016 18:07
by BakSeeDaa
gizmocuz wrote:Thats correct, with the new install method, you need to install additional software yourself, like the mosquito mqtt broker
this might work:
apt-get install mosquitto
Thanks @gizmocuz for Your kind help.
Just to be sure, Do I need to install the mosquito mqtt broker even though I don't wish to use MQTT? (I just want to be able to run commandArray['OpenURL'] using https )
Re: Can't open HTTPS URL:s using LUA script
Posted: Monday 28 November 2016 21:49
by BakSeeDaa
Maybe my questions sounds so weird... Yes, I'm still confused about this, I'm sorry for my ignorance.
Is it really necessary to define a "MQTT Client Gateway with LAN interface" hardware and to install mosquitto if I like to use LUA script to open a HTTPS URL using the commandArray (E.g. commandArray['OpenURL']='
https://somesite.com')
Re: Can't open HTTPS URL:s using LUA script
Posted: Tuesday 29 November 2016 7:04
by bizziebis
I think it's a certificate problem. You are trying to set up a secure connection so a valid certificate is expected. If you use a URL with a self-signed certificate its possible it doesn't work.
If you use the os.execute command you would issue a 'curl -k htps://....' command to ignore the SSL certificate.
Re: Can't open HTTPS URL:s using LUA script
Posted: Tuesday 29 November 2016 10:26
by BakSeeDaa
bizziebis wrote:I think it's a certificate problem. You are trying to set up a secure connection so a valid certificate is expected. If you use a URL with a self-signed certificate its possible it doesn't work.
If you use the os.execute command you would issue a 'curl -k htps://....' command to ignore the SSL certificate.
Thank You.
No, the problem is not the server certificate on the target host.
Summarizing
=================
Issuing the following command from the command line works great:
While the following LUA script will fail
Code: Select all
commandArray = {}
if (devicechanged['script_device_test'] == 'On') then
commandArray['OpenURL']='https://www.google.se/'
end
return commandArray
From the Domoticz error log:
Code: Select all
Error: Error opening url: https://www.google.se/
And to make everything more obscure... (sorry for that)
-If I create a "MQTT Client Gateway with LAN interface" hardware, the same LUA script above works fine. But I don't want to have a MQTT Client Gateway.
Current workaround solution:
I've made a LUA function used for calling URL:s
Code: Select all
function OpenURL(url)
if (string.find(url, 'https')) then
os.execute('curl -s \'' .. url .. '\' > /dev/null 2>&1 &')
else
commandArray[#commandArray+1]={['OpenURL']=url }
end
end