Page 1 of 1

http correct answer from socket or how to send http updates

Posted: Monday 26 November 2018 23:54
by Inso
Hi,

I have set up a socket on my pc via java to receive updates.
on dzVents, as soon as the device is updated, I send the new data as a Json string using

Code: Select all

domoticz.openURL(URL)
which works fine, data is sent. However, after a litte time domotics shows me the error:

Code: Select all

Error: Error opening url: http://192.168.178.24:4242/{"idx":"85","Name":"Lux StudyRoom Inside Table","Data":"0 Lux","Type":"Lux","LastUpdate":"2018-11-26 23:44:14"}
I assume it is because I just parse the received data. My question is: what "answer" is Domoticz waiting for, what do I have to send back? Or, is there a way to "fire and forget"-send data?

Re: http correct answer from socket or how to send http updates

Posted: Tuesday 27 November 2018 0:31
by waaren
Inso wrote: Monday 26 November 2018 23:54 I have set up a socket on my pc via java to receive updates.
I assume it is because I just parse the received data. My question is: what "answer" is Domoticz waiting for, what do I have to send back? Or, is there a way to "fire and forget"-send data?
Can you just return OK ? Domoticz does not like an empty response ( statusCode 52 ) and report an error in the log

Code: Select all

return 

{
        on  =   {   timer           = { "every minute"},
        -- on  =   {   timer           = { "never"},
                    httpResponses   = { 'getLog' },
                },
                
    logging =   {   level           =   domoticz.LOG_DEBUG,
                    marker          =   "dumper 7",
                },
    
    execute = function(dz, item )
    
        if item.isTimer then
            local json = '{"idx":"85","Name":"Lux StudyRoom Inside Table","Data":"0 Lux","Type":"Lux","LastUpdate":"2018-11-26 23:44:14"}'
            dz.openURL(
                            {   url         = "http://192.168.178.24:4242/" .. json,
                                method      = "GET",
                                callback    = "getLog" ,
                            }
                        )
        else
            dz.log(item.statusCode,dz.LOG_DEBUG)
            dz.log(item.data,dz.LOG_DEBUG)
        end
    end
}