Page 1 of 1

Python Framework - Not detecting connection issue

Posted: Monday 10 December 2018 17:16
by pipiche
I'm developing a plugin with the Python Framework and I'm having issue with connection failure.

I was under the impression that the plugin is capable to get information of connection issue, but it looks not !

Here are the 2 connection types I'm creating. The first one is using Serial (USB), the second is using TCP.
In both case, if I start the plugin, the connection is well established.

Then I unplug the USB stick or I powerOff the Wifi device on which there is the connection

And the when checking

Code: Select all

self._connection.Connected()
, it always report True !!!!! Despite the fact that I'm writting to the connection view the Send() method.
Of course when plugin back the USB Stick or PowerOn the Wifi device, nothing restart !

Code: Select all

self._connection = Domoticz.Connection(Name="ZiGate", Transport="Serial", Protocol="None",
                                                   Address=self._serialPort, Baud=115200)
self._connection = Domoticz.Connection(Name="Zigate", Transport="TCP/IP", Protocol="None ",
                                                   Address=self._wifiAddress, Port=self._wifiPort)

Re: Python Framework - Not detecting connection issue

Posted: Friday 21 December 2018 11:43
by pipiche
Did a test and it tooks 10 minutes for Domoticz to detect that the connection was aborted !!!!!! ( test made with a TCP/IP connection; I'll do a serial as well but do expect the same)

Coming from the Python Framework

Code: Select all

Dec 21 08:53:24 pi3 domoticz[3244]: 2018-12-21 08:53:24.312  Error: (ZigateWifi): Async Read Exception: 113, No route to host

Re: Python Framework - Not detecting connection issue

Posted: Friday 21 December 2018 23:25
by Dnpwwo
@pipiche,

This behaviour is standard for TCP/IP connections. If you turn off (or unplug) devices then the remote device does not have the opportunity to terminate the connection gracefully so the other end assumes it is still open. This is the reason that many protocols that go on top of TCP/IP have a heartbeat message capability so that the client can periodically test to see if the connection is still good. Also, some network devices (load balancers and firewalls) silently drop connections after a timeout period and 'pinging' prevents that.

I don't know much about ZiGate but it has a:
0x8017 Get Time server Response (v3.0f) <Timestamp UTC: uint32_t> from 2001-01-01 00:00:00
message that you could send from onHeartbeat that would tell you much quicker

Re: Python Framework - Not detecting connection issue

Posted: Saturday 22 December 2018 10:36
by pipiche
Thanks