Jump to content

Welcome to Smart Home Forum by FIBARO

Dear Guest,

 

as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.

 

As a member you can:

  •     Start new topics and reply to others
  •     Follow topics and users to get email updates
  •     Get your own profile page and make new friends
  •     Send personal messages
  •     ... and learn a lot about our system!

 

Regards,

Smart Home Forum by FIBARO Team


  • 0

HC3 QA TCP reconnection issue


TomBaro

Question

Hi everybody,

 

I'm using the TCP example code on this link

Please login or register to see this link.

 

Testing how reliably the connection is restored between the QA TCP client and an external third party server I found that sometimes Fibaro can't reconnect.

I physically disconnect the third party device by unplugging the RJ45 Ethernet connector, leaving it disconnected for a while and then reconnect it and check what's happening.

 

Sometimes the connection is succesfully restored and when I press a device "turn on" button, it is sent to the third party hardware and everything is fine, response is received.

[08.11.2020] [11:37:36 am] [DEBUG] [QUICKAPP572]: onAction: {"actionName":"turnOn","deviceId":573,"args":[573,"turnOn"]}

[08.11.2020] [11:37:36 am] [DEBUG] [QUICKAPP572]: child 573 channel1 turned on[08.11.2020] [11:37:36 am] [DEBUG] [QUICKAPP572]: command sent FN,ON,1

[08.11.2020] [11:37:36 am] [DEBUG] [QUICKAPP572]: onDataReceived >FN,OUT,ON,1 >[08.11.2020] [11:37:36 am] [DEBUG] [QUICKAPP572]: Command OUT param1 ON Channel 1

 

However other times nothing is sent and neither the success nor the failure callback functions are called

[08.11.2020] [11:33:39 am] [DEBUG] [QUICKAPP572]: onAction: {"args":[573,"turnOn"],"actionName":"turnOn","deviceId":573}

[08.11.2020] [11:33:39 am] [DEBUG] [QUICKAPP572]: child 573 channel1 turned on

and nothing else

 

It looks like Fibaro doesn't even try to send any commands. As if it wasn't aware of the connection. Most interestingly, monitoring the network shows that Fibaro responds to the server's keep alive messages, wich suggests that the low-level TCP socket connection is fine. It looks like the problem is with higher level Fibaro's socket handling. Sometimes the onInit() function is automatically called after a while which sorts out the connection. I just don't want to call onInit() unnecessarily from the QA code especially as I can't reliably detect when it is needed.

 

I've been stuck for a while, tried everything including adding a watchdog timer and using heartbeat messages but I can't really put my finger on anything. Fibaro randomly comes back with nothing, connection error, response error, etc. Unfortunately I can't see any pattern. It seems that the success and error callbacks are called randomly, they don't seem to have much to do with what's really happening.

 

Anybody with an insight? I can't really include any code as I've tried so many different versions and there's no pattern and it's hard to replicate the issue. I'm more after an expert who knows how Fibaro works behind the scenes or somebody who's experienced this and managed to get around it.

 

Thanks. 

Link to comment
Share on other sites

20 answers to this question

Recommended Posts

  • 0
47 minutes ago, TomBaro said:

Sometimes the onInit() function is automatically called after a while which sorts out the connection.

 

An automatic call of onInit() is a sign that your QA has crashed. Usually it tries to restart the QA immediately when it crash and then it goes into 1 minute intervals trying to start it again.

So, can it be that your code crashes in a handler for your network logic? Many crashes in async handlers tends to not generate any error messages...

 

47 minutes ago, TomBaro said:

Anybody with an insight? I can't really include any code as I've tried so many different versions and there's no pattern and it's hard to replicate the issue. I'm more after an expert who knows how Fibaro works behind the scenes or somebody who's experienced this and managed to get around it.   

 

One possible way forward is that you can try to run your code offline to decide if your Lua code has issues using my HC3 emulator 

It has net.TCPSocket() support. There you can step through the code and set breakpoints. If it works there you can really blame Fibaro :-)

 

  • Thanks 1
Link to comment
Share on other sites

  • 0

hi

 

totaly uncleary what you means. 

what TCP/Ip connection are you talking about

what third party server connection are you talking about... and why HC3 should restore TCP/Ip connection what it not created

 

Link to comment
Share on other sites

  • 0
  • Inquirer
  • 1 hour ago, jgab said:

     

    One possible way forward is that you can try to run your code offline to decide if your Lua code has issues using my HC3 emulator 

    It has net.TCPSocket() support. There you can step through the code and set breakpoints. If it works there you can really blame Fibaro :-)

     

    Wow, I couldn't have wished for anything better! Thank you. Looks like you've made a tool that makes HC3 QA development more straightforward instead of a trial and error exercise. I'll try it and share the outcome.

    Link to comment
    Share on other sites

    • 0
    11 minutes ago, TomBaro said:

    Wow, I couldn't have wished for anything better! Thank you. Looks like you've made a tool that makes HC3 QA development more straightforward instead of a trial and error exercise. I'll try it and share the outcome.

    There is a thread for that tool - if you post questions there I'm happy to support you to get you going. I would recommend ZeroBrane Studio but I know that @10der use it with VS.

    Edited by jgab
    • Thanks 1
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 1 hour ago, 10der said:

    hi

     

    totaly uncleary what you means. 

    what TCP/Ip connection are you talking about

    what third party server connection are you talking about... and why HC3 should restore TCP/Ip connection what it not created

     

    Sorry for being unclear, as I mentioned in my post I use the example code snippet of

    Please login or register to see this link.

    to connect to FutureNow units using TCP/IP socket communication. Everything else works fine but I've noticed that the reconnection is not always successful. More exactly it looks like Fibaro thinks it's not succesful even though the low-level reconnection seems fine according to Wireshark.

    This is the example code snippet I was referring to. The error() callback fuction in both the QuickAppwaitForResponseFunction() and the QuickApp:connect() functions contains the line that attemps the reconnection "fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s)"

     

    -- Quick App template for handling the TCP device
     
    function QuickApp:turnOn()
        self:debug("binary switch turned on")
        self:send("Some command for on\n") -- sending data to the device. In a normal implementation it will be a code with an appropriate command.
        self:updateProperty("value", true)
    end
     
    function QuickApp:turnOff()
        self:debug("binary switch turned off")
        self:send("Some command for off\n") -- sending data to the device. In a normal implementation it will be a code with an appropriate command.
        self:updateProperty("value", false)
    end
     
    -- the method for sending data to the device
    -- the method can be called from anywhere
    function QuickApp:send(strToSend)
        self.sock:write(strToSend, {
            success = function() -- the function that will be triggered when the data is correctly sent
                self:debug("data sent")
            end,
            error = function(err) -- the function that will be triggered in the event of an error in data transmission
                self:debug("error while sending data")
            end
        })
    end
     
    -- method for reading data from the socket
    -- since the method itself has been looped, it should not be called from other locations than QuickApp:connect
    function QuickApp:waitForResponseFunction()
        self.sock:read({ -- reading a data package from the socket
            success = function(data)
                self:onDataReceived(data) -- handling of received data
                self:waitForResponseFunction() -- looping of data readout
            end,
            error = function() -- a function that will be called in case of an error when trying to receive data, e.g. disconnecting a socket
                self:debug("response error")
                self.sock:close() -- socket closed
                fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s)
            end
        })
    end
     
    -- a method to open a TCP connection.
    -- if the connection is successful, the data readout loop will be called QuickApp:waitForResponseFunction()
    function QuickApp:connect()
        self.sock:connect(self.ip, self.port, { -- connection to the device with the specified IP and port
            success = function() -- the function will be triggered if the connection is correct
                self:debug("connected")
                self:send("Hello!\n")
                self:waitForResponseFunction() -- launching a data readout "loop"
            end,
            error = function(err) -- a function that will be triggered in case of an incorrect connection, e.g. timeout
                self.sock:close() -- closing the socket
                self:debug("connection error")
                fibaro.setTimeout(5000, function() self:connect() end) -- re-connection attempt (every 5s)
            end,
        })
    end
     
    -- function handling the read data
    -- normally this is where the data reported by the device will be handled
    function QuickApp:onDataReceived(data)
        self:debug("onDataReceived", data)
    end
     
    function QuickApp:onInit()
        self:debug("onInit")
     
        self.ip = self:getVariable("ip")
        self.port = tonumber(self:getVariable("port"))
     
        self.sock = net.TCPSocket() -- creation of a TCPSocket instance
        self:connect()
    end
     
     
     
     
    Link to comment
    Share on other sites

    • 0

    So I run this code in Zerobrane on a Mac using the fibaroapiHC3.lua

    Please login or register to see this code.

     

    In a terminal on the same mac I run 

    Please login or register to see this code.

    ...and I get a Hello printed!

    Haven't tried the reconnect yet.

     

    Link to comment
    Share on other sites

    • 0

    So I discovered a small bug in the TCP code. Pushed v0.142

     

    It seems like you can't connect a luasocket that has been closed. Can't do connect -> close -> connect

    Need to create a new socket.

     

    Please login or register to see this code.

    Moving the  

       self.sock = net.TCPSocket() -- creation of a TCPSocket instance

    to the QuickApp:connect() 

    makes the code reconnect after failures - in my simulator. However. it seems to be a luasocket design issue.

    Link to comment
    Share on other sites

    • 0
    1 hour ago, jgab said:

    So I discovered a small bug in the TCP code. Pushed v0.142

     

    It seems like you can't connect a luasocket that has been closed. Can't do connect -> close -> connect

    Need to create a new socket.

     

    Moving the  

       self.sock = net.TCPSocket() -- creation of a TCPSocket instance

    to the QuickApp:connect() 

    makes the code reconnect after failures - in my simulator. However. it seems to be a luasocket design issue.

     

    I can verify that creating a new TCPSocket works on the HC3 too.

    Seems like the socket is wasted after it is closed.

    • Thanks 1
    Link to comment
    Share on other sites

    • 0

    Actually, I take the back - kind of.

    As long as you don't close the socket at error you don't need to create a new socket.

    This works - and reconnects

    Please login or register to see this code.

     

    Edited by jgab
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 11/9/2020 at 8:43 PM, jgab said:

    Actually, I take the back - kind of.

    As long as you don't close the socket at error you don't need to create a new socket.

    This works - and reconnects

     

    Thanks a lot jgab! Does this mean that the example code I used is in error, or at least not the best way to do things?

     

    I've commented out the sock.close() line from both the connect() and the waitForResponseFunction() functions but something is still not right. Maybe there's something else wrong in the code.

     

    You really seem to be an expert at Lua and Fibaro, even your profile says so ;-) Could you please take a look at the code I've just tried and the log it produced.

     

    Here's the code with the irrelevant parts removed. A heartbeat (0x0D) is sent every 10 seconds to which the TCP server in the FutureNow unit responds with an > if the connection is alive. If there is no response three times the connect() function will be called.

     

    g_ReceiveBuffer=""

    function QuickApp:onInit()

        self:debug("QuickApp:onInit")

        self.watchdog=0

        self.ip = self:getVariable("IP address")

        self.sock = net.TCPSocket() -- creation of a TCPSocket instance

        self:connect()

        -- Setup classes for child devices.

        -- Here you can assign how child instances will be created.

        -- If type is not defined, QuickAppChild will be used.

     

        self:initChildDevices({

            ["com.fibaro.binarySwitch"] = MyBinarySwitch,

            ["com.fibaro.binarySensor"] = MyBinarySensor,

        })

        -- Print all child devices.

        self:debug("Child devices:")

        for id,device in pairs(self.childDevices) do

            self:debug("[", id, "]", device.name, ", type of: ", device.type, ", Channel No: ", device.channel)

        end

    end

    .

    .

    -- Methods to create a new child device for a FutureNow channel when an Add Channel button is pressed. As no custom properties are possible userDescription is used to store channel number

    -- creating and initialazing child devices - code removed

    .

    .

     

     

    function MyBinarySwitch:turnOn()

        self:debug("child", self.id, " channel" .. self.channel.. " turned on")

        command = "FN,ON,".. self.channel .. "\r"

        self.parent:send(command)

        self:updateProperty("value"true)

    end

     

     

    function MyBinarySwitch:turnOff()

        self:debug("child", self.id,  " Channel" .. self.channel.. " turned off")

        command = "FN,OFF," .. self.channel .. "\r"

        self.parent:send(command)

        self:updateProperty("value"false)

    end

     

    function QuickApp:connect()

        self:debug("socket is ", self.sock)

        --[[if (self.sock==nil) then -- if socket was lost

            self.ip = self:getVariable("IP address")

            self.sock = net.TCPSocket() -- creation of a TCPSocket instance

        end--]]

        self.sock:connect(self.ip, 7078, {

            success = function()-- the function will be triggered if the connection is correct

                self:debug("connected")

                --self:send("connected")

                --self:send("FN,SRE\r") --query output status to get HC3 in sync with the outputs

                --self:send("FN,SRI\r") --query input status to get HC3 in sync with the inputs

                self:send_heartbeat()

                self:waitForResponseFunction() -- launching a data readout "loop"

            end,

            error = function(err) -- a function that will be triggered in case of an incorrect connection, e.g. timeout

        -- self.sock:close() -- closing the socket

                self:debug("connection error")

                fibaro.setTimeout(5000function() self:connect() end-- re-connection attempt at every 5s

            end,

        })

    end

    function QuickApp:send_heartbeat()

        self:debug("watchdog counter =", self.watchdog)

        if self.watchdog > 2 then

            self:debug ("connection lost trying to reconnect")

            self:connect()

        else

            self:send("\r")

            self.watchdog = self.watchdog + 1

            fibaro.setTimeout(10000function() self:send_heartbeat() end)

        end

    end

    function QuickApp:send(strToSend)

        self.sock:write(strToSend, {

            success = function() -- the function that will be triggered when the data is correctly sent

                self:debug("command sent ", strToSend)

            end,

            error = function(err) -- the function that will be triggered in the event of an error in data transmission

                self:debug("error while sending data")

            end

        })

    end

    -- method for reading data from the socket

    -- since the method itself has been looped, it should not be called from other locations than QuickApp:connect

    function QuickApp:waitForResponseFunction()

        self.sock:read({ -- reading a data package from the socket

            success = function(data)

                self.watchdog = 0

                self:onDataReceived(data) -- handling of received data

                self:waitForResponseFunction() -- looping of data readout

            end,

            error = function() -- a function that will be called in case of an error when trying to receive data, e.g. disconnecting a socket

                self:debug("response error")

                --self.sock:close() -- socket closed

                fibaro.setTimeout(5000function() self:connect() end-- re-connection attempt (every 5s)

            end

        })

    end

    -- function for parsing the incoming data

    function QuickApp:onDataReceived(strData)

     

        -- code removed

     

        self:debug("onDataReceived", strData)

     

        -- code removed

     

    end

     

     

     

    Here is the log. In the beginning you can see that I turn a child device on and off. All fine. Then I disconnect the network. No answer to the heartbeat messages so the watchdog counter increases to three which causes the the connect() function to be called. Reconnection is attempted every 5 seconds and of course is unsuccesful as the network is physically disconnected. Then at around 10:06 pm I reconnect the network but as you can see reconnection takes a long time and all kinds of seemingly random things happen before things settle. Normally, without any user interaction you should only see these three lines in the debug window every 10 seconds.

     

    watchdog counter = 0

    command sent

    onDataReceived >

     

    When reconnecting I would expect an extra "connected" debug message, but that's all.

     

    Calling onInit() which creates a new socket at any point sorts things out but it would be a bit of an overkill and might create a new socket while leaving the previous one open which could result in multiple paralelly open sockets.

     

    [09.11.2020] [10:04:01 pm] [DEBUG] [QUICKAPP575]: command sent FN,ON,1

    [09.11.2020] [10:04:01 pm] [DEBUG] [QUICKAPP575]: onDataReceived >FN,OUT,ON,1 >

    [09.11.2020] [10:04:01 pm] [DEBUG] [QUICKAPP575]: Command OUT param1 ON Channel 1

    [09.11.2020] [10:04:02 pm] [DEBUG] [QUICKAPP575]: onAction: {"args":[576,"turnOff"],"actionName":"turnOff","deviceId":576}

    [09.11.2020] [10:04:02 pm] [DEBUG] [QUICKAPP575]: child 576 Channel1 turned off

    [09.11.2020] [10:04:02 pm] [DEBUG] [QUICKAPP575]: command sent FN,OFF,1

    [09.11.2020] [10:04:02 pm] [DEBUG] [QUICKAPP575]: onDataReceived >FN,OUT,OFF,1 >[09.11.2020] [10:04:02 pm] [DEBUG] [QUICKAPP575]: Command OUT param1 OFF Channel 1[09.11.2020] [10:04:05 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:04:05 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:04:15 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 1

    [09.11.2020] [10:04:15 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:04:25 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 2

    [09.11.2020] [10:04:25 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:04:35 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 3

    [09.11.2020] [10:04:35 pm] [DEBUG] [QUICKAPP575]: connection lost trying to reconnect

    [09.11.2020] [10:04:35 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:04:35 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:04:40 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:04:40 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:04:45 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:04:45 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:04:50 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:04:50 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:04:51 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:04:55 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:04:56 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:04:56 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:04:58 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:01 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:01 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:03 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:07 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:07 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:07 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:12 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:12 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:12 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:15 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:17 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:18 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:20 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:21 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:23 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:24 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:26 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:27 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:29 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:30 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:32 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:33 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:35 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:36 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:38 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:39 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:41 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:42 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:44 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:45 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:47 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:48 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:50 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:51 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:53 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:55 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:05:56 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:05:58 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:06:00 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:01 pm] [DEBUG] [QUICKAPP575]: connection error

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 3

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: connection lost trying to reconnect

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:03 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:06 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:06 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:06 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:06 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:06 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:06 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:06 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:08 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:08 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:08 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:08 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:08 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:08 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:08 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:11 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:11 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:11 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:11 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:11 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:11 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:11 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:13 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:16 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:18 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:21 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 1

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:23 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: command sent

    09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 1

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:26 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:28 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:31 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:33 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 1

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:36 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:38 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:41 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x32d59f30

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: response error

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: connected

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:43 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:46 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:46 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:46 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:46 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

    [09.11.2020] [10:06:46 pm] [DEBUG] [QUICKAPP575]: command sent

    [09.11.2020] [10:06:46 pm] [DEBUG] [QUICKAPP575]: onDataReceived >

    [09.11.2020] [10:06:46 pm] [DEBUG] [QUICKAPP575]: watchdog counter = 0

     

    Thanks in advance,

    Edited by TomBaro
    reformatting code
    Link to comment
    Share on other sites

    • 0

    Your included code example is badly formatted with a lot of newlines, very difficult to read - can you repost?

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 7 hours ago, jgab said:

    Your included code example is badly formatted with a lot of newlines, very difficult to read - can you repost?

    I've tried to edit it but it looks fine in the edit window, any idea what to do to make it look better? Edit - done, using an external text editor, sorry about that,

     

    Btw I've tried the code in the emulator but got different error messages, I'll have to play with it a bit more.

    I've also tried it with HC3 and a TCP server running on my laptop instead of the FutureNow unit and the debug window went totally wild with messages coming so quickly that it was impossble to even read them. It seemed as even if the timers didn't work. The only way I could stop them coming was to enter edit mode on HC3 which automatically runs onInit()

    Edited by TomBaro
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • Played with the HC3 emulator again. This is the error I'm receiving.

     

    QuickApp crashed: fibaroapiHC3.lua:1170: invalid value (table) at index 2 in table for 'concat'

     

    and this is line 1170 in fibaroapiHC3.lua

     

    function QuickAppBase:debug(...) fibaro.debug("",table.concat({...})) end -- Should we add _TAG ?
     

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • 7 minutes ago, TomBaro said:

    Played with the HC3 emulator again. This is the error I'm receiving.

     

    QuickApp crashed: fibaroapiHC3.lua:1170: invalid value (table) at index 2 in table for 'concat'

     

    and this is line 1170 in fibaroapiHC3.lua

     

    function QuickAppBase:debug(...) fibaro.debug("",table.concat({...})) end -- Should we add _TAG ?
     

    Commenting this line out helped.

     

    self:debug("socket is ", self.sock)

    Link to comment
    Share on other sites

    • 0
    5 hours ago, TomBaro said:

    Commenting this line out helped.

     

    self:debug("socket is ", self.sock)

     

    Ooops, the emulator has never been used to print/debug a socket... thanks, I have pushed a new version of the emulator v0.145 with some other fixes that was in the pipe too.

    Now it should write it out as something like "TCPSocket object: 0x37120580"

     

    ...so that was not your problem - that was my problem :-) 

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 11/11/2020 at 5:07 AM, jgab said:

     

    Ooops, the emulator has never been used to print/debug a socket... thanks, I have pushed a new version of the emulator v0.145 with some other fixes that was in the pipe too.

    Now it should write it out as something like "TCPSocket object: 0x37120580"

     

    ...so that was not your problem - that was my problem :-) 

     

    Your problem is also my problem :-)

     

    To be honest I'm not much closer to understanding what's happening. I guess it's something with how HC3 handles threads or sockets or how data is read from a socket.

    Tried to start everything from scratch and found that I can't even see received data in the emulator running the code you used to test TCP communication.  The same code receives data fine when run on HC3.

     

    Anyway, could you please shed some light on how looping waitforResponseFunction() is supposed to work and how exactly TCPSocket:read(callbacks) works? For example what does it do if there's nothing to read? When exactly are the success and error callback functions called? The same questions for TCPSocket:connect(ip, port, callbacks). The callback functions don't seem to work consistently to me but it's probably my ignorance or the lack of documentation.

    Do you think creating and using other loops that call themselves when a fibaro.setTimeout goes off can interfere with the waitforResponseFunction() loop?

    Edited by TomBaro
    adding clarification
    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • This is what I'm getting at the moment, not sure if the response error is a cause or a causation, definitely a cause that causes another delayed reconnection attempt but it's not clear what starts the whole circle. Tried to change the timings so that the reconnection attempts will be delayed differently depending on whether they are triggered by the waitforReponse() or Connect() functions when HC3 thinks something went wrong but I'm still no wiser.

     

    [15.11.2020] [09:36:37 pm] [DEBUG] [QUICKAPP575]: connected

    [15.11.2020] [09:36:37 pm] [DEBUG] [QUICKAPP575]: command sent connected

    [15.11.2020] [09:36:42 pm] [DEBUG] [QUICKAPP575]: socket is TCPSocket object: 0x1d91ab80

    [15.11.2020] [09:36:42 pm] [DEBUG] [QUICKAPP575]: response error Operation canceled

    [15.11.2020] [09:36:42 pm] [DEBUG] [QUICKAPP575]: connected

    [15.11.2020] [09:36:42 pm] [DEBUG] [QUICKAPP575]: command sent connected

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • No worries guys. It was a faulty power supply. Changing it sorted all the issues. Always think outside the box!!!

    Link to comment
    Share on other sites

    • 0
  • Inquirer
  • On 11/16/2020 at 7:46 PM, TomBaro said:

    No worries guys. It was a faulty power supply. Changing it sorted all the issues. Always think outside the box!!!

    Eventually it turned out it wasn't the power supply but a change I made around the same time. It was commenting out the reconnection line from QuickApp:waitForResponseFunction()

    Link to comment
    Share on other sites

    • 0

    Hi guys,

    thank you very much for your contribution which I took as reference for my development. I just wanted to share that in my case the socket had to be properly closed, otherwise, the QA  crashed. If self.sock:close() is not commented out, the QA reconnects without problem. I wrote the code as follows with self.sock = net.TCPSocket() inside the connect() function and it worked for me:

    function QuickApp:connect()

        self.sock = net.TCPSocket()

        self.sock:connect(self.ip, self.port, {

            success = function() 

                self:debug("Connected successfully.")

                self:debug("OK Socket is ", self.sock)

            end,

            error = function(err)

                self:debug("Connection error:",err)

                self.sock:close()

                self:debug("Error in Socket", self.sock)

                fibaro.setTimeout(5000, function() self:connect() end)

            end

        })

    end


    Best regards

    Link to comment
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Answer this question...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    ×
    ×
    • Create New...