Websocket connection dropping

  • Hi!
    I just bought the Unipi and I am getting familiar with possible interfaces. I must admit I am a bit dissaponted that there is no out of the box support for mqtt, as it is nowdays defacto standard for home automation, but it looks like websocket should do the job.

    Enough introduction, let's get to the point: After I set the filter to DI only, the incomming streaming stops as expected. But after some period the connection drops. What could be the reason for that? Is there an IDLE timeout? Should I be sending some keepalives? I haven't played with watchdogs; I suppose they are disabled by default?

    Thanx and regards,

  • administrators

    Hi @oversc0re!

    What sort of dropout periods you are seeing? The websocket interface doesn't have keepalive pings enabled (though they are implemented in the library we are using) so that shouldn't be an issue; that said the problems could still be caused by an idle timeout somewhere along the line, so sending an occasional 'all' command might help.

    We have a simple websocket-to-mqtt interface written in python which we use internally, and that is capable of keeping the connection going for weeks on end - though I presume there is some form of reconnection code in that program (I haven't looked at it recently enough to recall it offhand).

  • Hi @tomas_knot,
    I have a simple script in Node-red although i will probably be writing a python script sooner or later.
    The connection is reconnected immediately but the filter settings are gone and I have to reapply them. This happens a minute or two after filters are applied.
    Does filtering out all the unnecessary streaming actually improve response time of digital input notifications?

    Thanx and regards

  • administrators


    The response time doesn't really improve, the intended use is to allow for multiple differentiated connections which listen at the same time.

    That said, the drops you are seeing do not usually happen. I'm inclined to think there are timeouts somewhere on the line from EVOK to Node-red, but it's hard to debug from our point of view. Do you still have the same issues if you send an occasional 'all' command? It shouldn't be necessary but it might help in your case.

  • Hello,
    yup, sending cmd:all every minute prevents the connection drop.

    Even though, I don't feell like writing a state machine for blinds in node-red is a good idea. I will test this behavior while migrating to python along the way.

    Regards, Matic

  • @tomas_knot Hi, Would it be possible to share this websocket to MQTT script? I have a websocket configured now that runs all the time (perfectly stable btw) and inititates a rest call to update a Domoticz switch if needed, however I would like to explore making this push pull with MQTT for myself te learn and to see if that's a bit more resources friendly.

  • administrators

    The websocket-to-MQTT is part of a wider array of scripts used in our company, which include a number of proprietary details, so we unfortunately cannot share it without extensive modification. We may at some point in a future, but we need to discuss it internally first.


  • @tomas_knot ok, thanks for responding. Love to see MQTT into the base neuron by default in the future.

Log in to reply

Looks like your connection to UniPi.technology Forum was lost, please wait while we try to reconnect.