How to catch an asynchronous HTTP not responding

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

How to catch an asynchronous HTTP not responding

Post by Number8 »

Hello,
In case a web server does not respond to an asynchronous HTTP request, as expected there is a timeout and dzVents logs in red full details of the calling url (including sensitive information). Is there a way to catch the timeout before it is logged by dzVents runtime?
Thank you

Running dzVents 3.0.9
Debian buster on NUC and three RPi with buster.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by waaren »

Number8 wrote: Friday 04 September 2020 16:46 In case a web server does not respond to an asynchronous HTTP request, as expected there is a timeout and dzVents logs in red full details of the calling url (including sensitive information). Is there a way to catch the timeout before it is logged by dzVents runtime?
If you mean the error message like 2020-09-04 17:31:00.559 Error: Error opening url: http: //somedomain/someAPI?param=1
then the message you see is not generated by dzVents but in core domoticz. Messages from dzVents will show the text "dzVents" somewhere in the logline.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by Number8 »

Yes I mean this message, no way to catch it?
Debian buster on NUC and three RPi with buster.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by waaren »

Number8 wrote: Friday 04 September 2020 18:52 Yes I mean this message, no way to catch it?
You will have to modify the domoticz source code and compile locally to achieve that.

A workaround could be to check the url (ping or another tool) before sending the real thing.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Number8
Posts: 374
Joined: Friday 23 May 2014 7:55
Target OS: Linux
Domoticz version: 2022.1
Location: Saint Pierre de Jards
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by Number8 »

At first place I had the idea to use ping. But it does not answer the case where the network is up and the service is down. I might give a shot to modify the module that send the error message. Any direction to search for?
Debian buster on NUC and three RPi with buster.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by waaren »

Number8 wrote: Saturday 05 September 2020 9:45 At first place I had the idea to use ping. But it does not answer the case where the network is up and the service is down. I might give a shot to modify the module that send the error message. Any direction to search for?
In latest Beta

Code: Select all

main/SQLHelper.cpp:3516:           _log.Log(LOG_ERR, "Error opening url: %s", itt->_sValue.c_str());
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
zicht
Posts: 300
Joined: Sunday 11 May 2014 11:09
Target OS: Windows
Domoticz version: 2023.1+
Location: NL
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by zicht »

Hi

No need to modify files.

In Lua and DZ :
You could use curl, but be aware it could freeze domoticz for a couple of seconds.
WIth curl you can set max time to open and max time to wait for the request to finisch.
If you set both at max 9 seconds you will never see the error.

See curl documentation depending on you platform, this can be done on linux AND windows systems
windows example :
"start /b /realtime curl.exe --connect-timeout 5 --max-time 9"
Works fine for me on most http requests. The Start /b / realtime is just to get highest priority on windows curl.

Also you need to implement a check on valid data, you could endup with a empty response or a partial response.
Imagination is the limit. good luck with your approach.
Rpi & Win x64. Using : cam's,RFXCom, LaCrosse, RFY, HuE, google, standard Lua, Tasker, Waze traveltime, NLAlert&grip2+,curtains, vacuum, audioreceiver, smart-heating&cooling + many more (= automate all repetitive simple tasks)
User avatar
kiddigital
Posts: 447
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by kiddigital »

Number8 wrote:Yes I mean this message, no way to catch it?
Do you have a few example loglines showing what you are trying to catch?

Most Domoticz hardware devices that talk to some API over http do this in a synchronous way. Errors like time-outs or other failures have to be handled within the implementation code of the devices themselves.
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by waaren »

kiddigital wrote: Sunday 06 September 2020 10:14 Most Domoticz hardware devices that talk to some API over http do this in a synchronous way. Errors like time-outs or other failures have to be handled within the implementation code of the devices themselves.
This question is about the (async) openURL call in dzVents
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
User avatar
kiddigital
Posts: 447
Joined: Thursday 10 August 2017 6:52
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to catch an asynchronous HTTP not responding

Post by kiddigital »

waaren wrote:...
This question is about the (async) openURL call in dzVents
Ah.. ok Image
One RPi with Domoticz, RFX433e, aeon labs z-wave plus stick GEN5, ha-bridge 5.4.0 for Alexa, Philips Hue Bridge, Pimoroni Automation Hat
One RPi with Pi foundation standard touch screen to display Dashticz
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest