Page 1 of 1

Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file

Posted: Tuesday 20 April 2021 14:14
by Sarcas
I use a little script that gets weather info for me every 15 minutes. Sometimes it errors a lot. I don’t really understand what is going on, and if i can fix it. Most of the times it sees to work.

The script

Code: Select all

--  https://openweathermap.org/api/one-call-api
-- 

return {
	on = {
		timer = {
			'every 15 minutes'
		},
		httpResponses = {
			'OWMForecastFunc'
		}
	},
	execute = function(domoticz, item)
	    local API_id    = “123myapi123"
        local latitude  = domoticz.settings.location.latitude
        local longitude = domoticz.settings.location.longitude

		if (item.isTimer) then
			domoticz.openURL({
                    url = 'http://api.openweathermap.org/data/2.5/onecall?lat=' .. latitude .. '&' .. 'lon=' .. longitude ..'&lang=nl&APPID=' .. API_id .. '&units=metric',
				method      = 'GET',
				callback    = 'OWMForecastFunc',
			})
		end

		if (item.isHTTPResponse) then
			if (item.ok) then
				if (item.isJSON) then
                    domoticz.globalData.OWMForecast = item.json
                    domoticz.emitEvent('OWMForecastUpdated')
				end
			else
				domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
				domoticz.log(item, domoticz.LOG_ERROR)
			end
		end
	end
}
The errors

Code: Select all

2021-04-20 09:00:16.920 Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file
2021-04-20 09:00:16.920 Error: dzVents: Error: (3.1.7) {["statusText"]="Transferred a partial file", ["statusCode"]=18, ["isGroup"]=false, ["data"]="", ["isTimer"]=false, ["isScene"]=false, ["isVariable"]=false, ["ok"]=false, ["isJSON"]=false, ["isShellCommandResponse"]=false, ["isSecurity"]=false, ["isHTTPResponse"]=true, ["isDevice"]=false, ["isXML"]=false, ["trigger"]="OWMForecastFunc", ["protocol"]="HTTP/1.1", ["baseType"]="httpResponse", ["isCustomEvent"]=false, ["callback"]="OWMForecastFunc", ["dump"]=function, ["_contentType"]="application/json; charset=utf-8", ["isHardware"]=false, ["isSystem"]=false, ["headers"]={["Access-Control-Allow-Credentials"]="true", ["Server"]="openresty", ["Connection"]="keep-alive", ["Access-Control-Allow-Origin"]="*", ["X-Cache-Key"]="/data/2.5/onecall?APPID=123&lang=nl&lat=123&lon=6.13&units=metric", ["Content-Length"]="19441", ["Content-Type"]="application/json; charset=utf-8", ["Access-Control-Allow-Methods"]="GET, POST", ["Date"]="Tue, 20 Apr 2021 07:00:06 GMT"}}
2021-04-20 11:00:38.647 Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file
2021-04-20 11:00:38.648 Error: dzVents: Error: (3.1.7) {["isXML"]=false, ["isDevice"]=false, ["isGroup"]=false, ["_contentType"]="application/json; charset=utf-8", ["statusText"]="Transferred a partial file", ["isTimer"]=false, ["headers"]={["X-Cache-Key"]="/data/2.5/onecall?APPID=123&lang=nl&lat=123&lon=6.13&units=metric", ["Content-Type"]="application/json; charset=utf-8", ["Server"]="openresty", ["Date"]="Tue, 20 Apr 2021 09:00:06 GMT", ["Access-Control-Allow-Credentials"]="true", ["Access-Control-Allow-Origin"]="*", ["Access-Control-Allow-Methods"]="GET, POST", ["Content-Length"]="19461", ["Connection"]="keep-alive"}, ["isSystem"]=false, ["data"]="{"lat”:123,"lon":6.1286,"timezone":"Europe/Amsterdam","timezone_offset":7200,"current":{"dt":1618909204,"sunrise":1618892664,"sunset":1618944237,"temp":11.54,"feels_like":11.02,"pressure":1019,"humidity":87,"dew_point":9.45,"uvi":2.82,"clouds":54,"visibility":10000,"wind_speed":3.6,"wind_deg":50,"weather":[{"id":803,"main":"Clouds","description":"half bewolkt","icon":"04d"}]},"minutely":[{"dt":1618909260,"precipitation":0},{"dt":1618909320,"precipitation":0},{"dt":1618909380,"precipitation":0},{"dt":1618909440,"precipitation":0},{"dt":1618909500,"precipitation":0},{"dt":1618909560,"precipitation":0},{"dt":1618909620,"precipitation":0},{"dt":1618909680,"precipitation":0},{"dt":1618909740,"precipitation":0},{"dt":1618909800,"precipitation":0},{"dt":1618909860,"precipitation":0},{"dt":1618909920,"precipitation":0},{"dt":1618909980,"precipitation":0},{"dt":1618910040,"precipitation":0},{"dt":1618910100,"precipitation":0},{"dt":1618910160,"precipitation":0},{"dt":1618910220,"precipitation":0},{"dt":1618910280,"precipitation":0},{"dt":1618910340,"precipitation":0},{"dt":1618910400,"precipitation":0},{"dt":1618910460,"precipitation":0},{"dt":1618910520,"precipitation":0},{"dt":1618910580,"precipitation":0},{"dt":1618910640,"precipitation":0},{"dt":1618910700,"precipitation":0},{"dt":1618910760,"precipitation":0},{"dt":1618910820,"precipitation":0},{"dt":1618910880,"precipitation":0},{"dt":1618910940,"precipitation":0},{"dt":1618911000,"precipitation":0},{"dt":1618911060,"precipitation":0},{"dt":1618911120,"precipitation":0},{"dt":1618911180,"precipitation":0},{"dt":1618911240,"precipitation":0},{"dt":1618911300,"precipitation":0},{"dt":1618911360,"precipitation":0},{"dt":1618911420,"precipitation":0},{"dt":1618911480,"precipitation":0},{"dt":1618911540,"precipitation":0},{"dt":1618911600,"precipitation":0},{"dt":1618911660,"precipitation":0},{"dt":1618911720,"precipitation":0},{"dt":1618911780,"precipitation":0},{"dt":1618911840,"precipitation":0},{"dt":1618911900,"precipitation":0},{"dt":1618911960,"precipitation":0},{"dt":1618912020,"precipitation":0},{"dt":1618912080,"precipitation":0},{"dt":1618912140,"precipitation":0},{"dt":1618912200,"precipitation":0},{"dt":1618912260,"precipitation":0},{"dt":1618912320,"precipitation":0},{"dt":1618912380,"precipitation":0},{"dt":1618912440,"precipitation":0},{"dt":1618912500,"precipitation":0},{"dt":1618912560,"precipitation":0},{"dt":1618912620,"precipitation":0},{"dt":1618912680,"precipitation":0},{"dt":1618912740,"precipitation":0},{"dt":1618912800,"precipitation":0},{"dt":1618912860,"precipitation":0}],"hourly":[{"dt":1618909200,"temp":11.54,"feels_like":11.02,"pressure":1019,"humidity":87,"dew_point":9.45,"uvi":2.82,"clouds":54,"visibility":10000,"wind_speed":3.28,"wind_deg":65,"wind_gust":4.37,"weather":[{"id":803,"main":"Clouds","description":"half bewolkt","icon":"04d"}],"pop":0},{"dt":1618912800,"temp":11.71,"feels_like":11.05,"pressure":1019,"humidity":81,"dew_point":8.56,"uvi":3.91,"clouds":52,"visibility":10000,"wind_speed":3.31,"wind_deg":63,"wind_gust":4.1,"weather":[{"id":803,"main":"Clouds","description":"half bewolkt","icon":"04d"}],"pop":0},{"dt":1618916400,"temp":12.18,"feels_like":11.41,"pressure":1019,"humidity":75,"dew_point":7.89,"uvi":4.54,"clouds":47,"visibility":10000,"wind_speed":3.2,"wind_deg":59,"wind_gust":3.6,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}],"pop":0},{"dt":1618920000,"temp":12.77,"feels_like":11.88,"pressure":101", ["isHTTPResponse"]=true, ["trigger"]="OWMForecastFunc", ["callback"]="OWMForecastFunc", ["ok"]=false, ["isJSON"]=false, ["isCustomEvent"]=false, ["isScene"]=false, ["baseType"]="httpResponse", ["statusCode"]=18, ["isHardware"]=false, ["isVariable"]=false, ["isSecurity"]=false, ["dump"]=function, ["protocol"]="HTTP/1.1", ["isShellCommandResponse"]=false}
2021-04-20 11:30:23.760 Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file
2021-04-20 11:30:23.762 Error: dzVents: Error: (3.1.7) {["ok"]=false, ["data"]="{"lat”:123,"lon":6.1286,"timezone":"Europe/Amsterdam","timezone_offset":7200,"current":{"dt":1618911012,"sunrise":1618892664,"sunset":1618944237,"temp":12.31,"feels_like":11.87,"pressure":1019,"humidity":87,"dew_point":10.21,"uvi":3.91,"clouds":45,"visibility":10000,"wind_speed":2.57,"wind_deg":50,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}]},"minutely":[{"dt":1618911060,"precipitation":0},{"dt":1618911120,"precipitation":0},{"dt":1618911180,"precipitation":0},{"dt":1618911240,"precipitation":0},{"dt":1618911300,"precipitation":0},{"dt":1618911360,"precipitation":0},{"dt":1618911420,"precipitation":0},{"dt":1618911480,"precipitation":0},{"dt":1618911540,"precipitation":0},{"dt":1618911600,"precipitation":0},{"dt":1618911660,"precipitation":0},{"dt":1618911720,"precipitation":0},{"dt":1618911780,"precipitation":0},{"dt":1618911840,"precipitation":0},{"dt":1618911900,"precipitation":0},{"dt":1618911960,"precipitation":0},{"dt":1618912020,"precipitation":0},{"dt":1618912080,"precipitation":0},{"dt":1618912140,"precipitation":0},{"dt":1618912200,"precipitation":0},{"dt":1618912260,"precipitation":0},{"dt":1618912320,"precipitation":0},{"dt":1618912380,"precipitation":0},{"dt":1618912440,"precipitation":0},{"dt":1618912500,"precipitation":0},{"dt":1618912560,"precipitation":0},{"dt":1618912620,"precipitation":0},{"dt":1618912680,"precipitation":0},{"dt":1618912740,"precipitation":0},{"dt":1618912800,"precipitation":0},{"dt":1618912860,"precipitation":0},{"dt":1618912920,"precipitation":0},{"dt":1618912980,"precipitation":0},{"dt":1618913040,"precipitation":0},{"dt":1618913100,"precipitation":0},{"dt":1618913160,"precipitation":0},{"dt":1618913220,"precipitation":0},{"dt":1618913280,"precipitation":0},{"dt":1618913340,"precipitation":0},{"dt":1618913400,"precipitation":0},{"dt":1618913460,"precipitation":0},{"dt":1618913520,"precipitation":0},{"dt":1618913580,"precipitation":0},{"dt":1618913640,"precipitation":0},{"dt":1618913700,"precipitation":0},{"dt":1618913760,"precipitation":0},{"dt":1618913820,"precipitation":0},{"dt":1618913880,"precipitation":0},{"dt":1618913940,"precipitation":0},{"dt":1618914000,"precipitation":0},{"dt":1618914060,"precipitation":0},{"dt":1618914120,"precipitation":0},{"dt":1618914180,"precipitation":0},{"dt":1618914240,"precipitation":0},{"dt":1618914300,"precipitation":0},{"dt":1618914360,"precipitation":0},{"dt":1618914420,"precipitation":0},{"dt":1618914480,"precipitation":0},{"dt":1618914540,"precipitation":0},{"dt":1618914600,"precipitation":0},{"dt":1618914660,"precipitation":0}],"hourly":[{"dt":1618909200,"temp":12.08,"feels_like":11.48,"pressure":1019,"humidity":82,"dew_point":9.1,"uvi":2.82,"clouds":47,"visibility":10000,"wind_speed":3.28,"wind_deg":65,"wind_gust":4.37,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}],"pop":0},{"dt":1618912800,"temp":12.31,"feels_like":11.87,"pressure":1019,"humidity":87,"dew_point":10.21,"uvi":3.91,"clouds":45,"visibility":10000,"wind_speed":3.31,"wind_deg":63,"wind_gust":4.1,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}],"pop":0},{"dt":1618916400,"temp":12.47,"feels_like":11.89,"pressure":1019,"humidity":81,"dew_point":9.3,"uvi":4.54,"clouds":43,"visibility":10000,"wind_speed":3.2,"wind_deg":59,"wind_gust":3.6,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}],"pop":0},{"dt":1618920000,"temp":12.82,"feels_like":12.09,"pressure"", ["statusText"]="Transferred a partial file", ["protocol"]="HTTP/1.1", ["isShellCommandResponse"]=false, ["headers"]={["Date"]="Tue, 20 Apr 2021 09:30:13 GMT", ["X-Cache-Key"]="/data/2.5/onecall?APPID=123&lang=nl&lat=123&lon=6.13&units=metric", ["Server"]="openresty", ["Access-Control-Allow-Methods"]="GET, POST", ["Connection"]="keep-alive", ["Access-Control-Allow-Credentials"]="true", ["Content-Type"]="application/json; charset=utf-8", ["Access-Control-Allow-Origin"]="*", ["Content-Length"]="19464"}, ["statusCode"]=18, ["baseType"]="httpResponse", ["dump"]=function, ["isCustomEvent"]=false, ["isHTTPResponse"]=true, ["_contentType"]="application/json; charset=utf-8", ["isTimer"]=false, ["isSecurity"]=false, ["isSystem"]=false, ["isVariable"]=false, ["isHardware"]=false, ["trigger"]="OWMForecastFunc", ["isXML"]=false, ["callback"]="OWMForecastFunc", ["isGroup"]=false, ["isScene"]=false, ["isDevice"]=false, ["isJSON"]=false}
2021-04-20 12:00:17.134 Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file
2021-04-20 12:00:17.140 Error: dzVents: Error: (3.1.7) {["isTimer"]=false, ["isJSON"]=false, ["isSystem"]=false, ["isXML"]=false, ["ok"]=false, ["isCustomEvent"]=false, ["baseType"]="httpResponse", ["statusCode"]=18, ["_contentType"]="application/json; charset=utf-8", ["trigger"]="OWMForecastFunc", ["data"]="{"lat”:123,"lon":6.1286,"timezone":"Europe/Amsterdam","timezone_offset":7200,"current":{"dt":1618912803,"sunrise":1618892664,"sunset":1618944237,"temp":14.46,"feels_like":13.79,"pressure":1016,"humidity":70,"dew_point":9.06,"uvi":3.91,"clouds":45,"visibility":10000,"wind_speed":0.89,"wind_deg":36,"wind_gust":4.02,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}]},"minutely":[{"dt":1618912860,"precipitation":0},{"dt":1618912920,"precipitation":0},{"dt":1618912980,"precipitation":0},{"dt":1618913040,"precipitation":0},{"dt":1618913100,"precipitation":0},{"dt":1618913160,"precipitation":0},{"dt":1618913220,"precipitation":0},{"dt":1618913280,"precipitation":0},{"dt":1618913340,"precipitation":0},{"dt":1618913400,"precipitation":0},{"dt":1618913460,"precipitation":0},{"dt":1618913520,"precipitation":0},{"dt":1618913580,"precipitation":0},{"dt":1618913640,"precipitation":0},{"dt":1618913700,"precipitation":0},{"dt":1618913760,"precipitation":0},{"dt":1618913820,"precipitation":0},{"dt":1618913880,"precipitation":0},{"dt":1618913940,"precipitation":0},{"dt":1618914000,"precipitation":0},{"dt":1618914060,"precipitation":0},{"dt":1618914120,"precipitation":0},{"dt":1618914180,"precipitation":0},{"dt":1618914240,"precipitation":0},{"dt":1618914300,"precipitation":0},{"dt":1618914360,"precipitation":0},{"dt":1618914420,"precipitation":0},{"dt":1618914480,"precipitation":0},{"dt":1618914540,"precipitation":0},{"dt":1618914600,"precipitation":0},{"dt":1618914660,"precipitation":0},{"dt":1618914720,"precipitation":0},{"dt":1618914780,"precipitation":0},{"dt":1618914840,"precipitation":0},{"dt":1618914900,"precipitation":0},{"dt":1618914960,"precipitation":0},{"dt":1618915020,"precipitation":0},{"dt":1618915080,"precipitation":0},{"dt":1618915140,"precipitation":0},{"dt":1618915200,"precipitation":0},{"dt":1618915260,"precipitation":0},{"dt":1618915320,"precipitation":0},{"dt":1618915380,"precipitation":0},{"dt":1618915440,"precipitation":0},{"dt":1618915500,"precipitation":0},{"dt":1618915560,"precipitation":0},{"dt":1618915620,"precipitation":0},{"dt":1618915680,"precipitation":0},{"dt":1618915740,"precipitation":0},{"dt":1618915800,"precipitation":0},{"dt":1618915860,"precipitation":0},{"dt":1618915920,"precipitation":0},{"dt":1618915980,"precipitation":0},{"dt":1618916040,"precipitation":0},{"dt":1618916100,"precipitation":0},{"dt":1618916160,"precipitation":0},{"dt":1618916220,"precipitation":0},{"dt":1618916280,"precipitation":0},{"dt":1618916340,"precipitation":0},{"dt":1618916400,"precipitation":0},{"dt":1618916460,"precipitation":0}],"hourly":[{"dt":1618912800,"temp":14.46,"feels_like":13.79,"pressure":1016,"humidity":70,"dew_point":9.06,"uvi":3.91,"clouds":45,"visibility":10000,"wind_speed":3.31,"wind_deg":63,"wind_gust":4.1,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}],"pop":0},{"dt":1618916400,"temp":14.19,"feels_like":13.41,"pressure":1016,"humidity":67,"dew_point":8.16,"uvi":4.54,"clouds":43,"visibility":10000,"wind_speed":3.2,"wind_deg":59,"wind_gust":3.6,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}],"pop":0},{"dt":1618920000,"temp":14.11,"feels_like":13.25,"pressure":1017,"humidity":64,"dew_point":7.41,"uvi":4.6,"clouds":39,"visibility":10000,"wind_speed":3.39,"wind_deg":48,"wind_gust":3.51,"weather":[{"id":802,"main":"Clouds","description":"licht bewolkt","icon":"03d"}],"pop":0},{"dt":1618923600,"temp":14,"feels_like":13.", ["isVariable"]=false, ["isGroup"]=false, ["isHardware"]=false, ["isScene"]=false, ["protocol"]="HTTP/1.1", ["isSecurity"]=false, ["callback"]="OWMForecastFunc", ["isHTTPResponse"]=true, ["isShellCommandResponse"]=false, ["isDevice"]=false, ["headers"]={["Server"]="openresty", ["Content-Type"]="application/json; charset=utf-8", ["Date"]="Tue, 20 Apr 2021 10:00:03 GMT", ["Content-Length"]="19478", ["Access-Control-Allow-Methods"]="GET, POST", ["Access-Control-Allow-Credentials"]="true", ["Access-Control-Allow-Origin"]="*", ["X-Cache-Key"]="/data/2.5/onecall?APPID=123&lang=nl&lat=123&lon=6.13&units=metric", ["Connection"]="keep-alive"}, ["dump"]=function, ["statusText"]="Transferred a partial file"}
2021-04-20 13:30:13.280 Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file
2021-04-20 13:30:13.280 Error: dzVents: Error: (3.1.7) {["isVariable"]=false, ["statusCode"]=18, ["statusText"]="Transferred a partial file", ["isXML"]=false, ["isShellCommandResponse"]=false, ["isHardware"]=false, ["isSecurity"]=false, ["callback"]="OWMForecastFunc", ["baseType"]="httpResponse", ["dump"]=function, ["isTimer"]=false, ["isSystem"]=false, ["isCustomEvent"]=false, ["isGroup"]=false, ["isScene"]=false, ["headers"]={["Date"]="Tue, 20 Apr 2021 11:30:03 GMT", ["Content-Length"]="19490", ["Access-Control-Allow-Methods"]="GET, POST", ["Server"]="openresty", ["Access-Control-Allow-Origin"]="*", ["Connection"]="keep-alive", ["Content-Type"]="application/json; charset=utf-8", ["Access-Control-Allow-Credentials"]="true", ["X-Cache-Key"]="/data/2.5/onecall?APPID=123&lang=nl&lat=123&lon=6.13&units=metric"}, ["isJSON"]=false, ["isHTTPResponse"]=true, ["ok"]=false, ["_contentType"]="application/json; charset=utf-8", ["protocol"]="HTTP/1.1", ["data"]="", ["trigger"]="OWMForecastFunc", ["isDevice"]=false}

Re: Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file

Posted: Tuesday 20 April 2021 15:02
by akamming
dzVents does a call to the libcurl library and just reports the error back, which you can find on the libcurl-errors manpage (https://linux.die.net/man/3/libcurl-errors):

Code: Select all

CURLE_PARTIAL_FILE (18)
A file transfer was shorter or larger than expected. This happens when the server first reports an expected transfer size, and then delivers data that doesn't match the previously given size.
seems to be a serverside issue

Re: Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file

Posted: Tuesday 20 April 2021 15:04
by waaren
Sarcas wrote: Tuesday 20 April 2021 14:14 I use a little script that gets weather info for me every 15 minutes. Sometimes it errors a lot. I don’t really understand what is going on, and if i can fix it. Most of the times it sees to work.
It looks like the response from OWM tells domoticz that the result-data from OWM might be incomplete. This prevents dzVents from automatically converting the JSON into a Lua table.

Can you try below modified version?

Code: Select all

--  https://openweathermap.org/api/one-call-api
--

return {
    on = {
        timer = {
            'every 15 minutes'
        },
        httpResponses = {
            'OWMForecastFunc'
        }
    },

    execute = function(domoticz, item)
        local API_id    = “123myapi123"
        local latitude  = domoticz.settings.location.latitude
        local longitude = domoticz.settings.location.longitude

        local function processData(item)
            local myJSON = item.json or domoticz.utils.fromJSON(item.data)
            if myJSON then
                domoticz.globalData.OWMForecast = myJSON
                domoticz.emitEvent('OWMForecastUpdated')
            else
                domoticz.log('There was a problem handling the request', domoticz.LOG_ERROR)
                domoticz.log(item, domoticz.LOG_DEBUG)
            end
        end

        if item.isTimer then
            domoticz.openURL({
                url = 'http://api.openweathermap.org/data/2.5/onecall?lat=' .. latitude .. '&' .. 'lon=' .. longitude ..'&lang=nl&APPID=' .. API_id .. '&units=metric',
                method      = 'GET',
                callback    = 'OWMForecastFunc',
            })
        elseif item.isHTTPResponse then
            processData(item)
        end
    end
}



Re: Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file

Posted: Wednesday 21 April 2021 11:18
by Sarcas
Hi waaren,

Thank you. I have activated your version and will check the logs later to see how it is doing.

Can you explain these lines to me? I am trying to learn :)

Code: Select all

local myJSON = item.json or domoticz.utils.fromJSON(item.data)
if myJSON then
Thanks again!

S.

Re: Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file

Posted: Wednesday 21 April 2021 12:48
by waaren
Sarcas wrote: Wednesday 21 April 2021 11:18 Can you explain these lines to me? I am trying to learn :)

Code: Select all

local myJSON = item.json or domoticz.utils.fromJSON(item.data)
if myJSON then
Let me try :)

Code: Select all

local myJSON = item.json or domoticz.utils.fromJSON(item.data)
local myJSON is telling the Lua interpreter that it should reserve a pointer to a memory location for the variable myJSON that will only be accessible within its current block. A block can be a function, - an if-end, - repeat-until while-end, etc ..

item.json is here a Lua table created during the automatic conversion of the JSON string item.data. If that conversion failed or if the conversion did not take place item.json is nil

The right partof the or will only be evaluated if the left part is either nil or false. So here it will force a conversion of the JSON string item.data to a Lua table when item.json is nil

The result of this line is that myJSON will either contain the automatically converted JSON string or the forced converted JSON string or nil when the forced conversion failed.

In your failing version the automatically conversion will not take place when the returncode of the http call is not between 200-300 because dzVents then assume the call failed (which it partially does because of the incompleteness or the return).

Re: Error: dzVents: Error: (3.1.7) HTTP/1.1 response: 18 ==>> Transferred a partial file

Posted: Sunday 09 May 2021 9:03
by Sarcas
Thank you for the explanation! I’d never think of that. I like the compactness :)

The errors are way less frequent now btw.

Code: Select all

2021-05-08 22:30:10.082 Error: EventSystem: Warning!, lua script /home/pi/domoticz/dzVents/runtime/dzVents.lua has been running for more than 10 seconds
2021-05-08 22:30:20.832 Error: Error opening url: http://api.openweathermap.org/data/2.5/onecall?lat=53&lon=6&lang=nl&APPID=myapi&units=metric
2021-05-08 22:30:20.984 Error: dzVents: Error: (3.1.8) HTTP/1.1 response: 18 ==>> Transferred a partial file
2021-05-08 22:30:20.984 Error: dzVents: Error: (3.1.8) Error parsing json to LUA table: (invalid json string) 
Not sure what is causing these hiccups, but I am migrating from my old rpi to a new rpi4 so maybe that will help.

Thanks!

S.