Losing connection to MySensors Gateway 0.71.0

Is anyone else getting connection drops from their MySensors gateway in the latest update?
After about a day from a restart of HA the connection to the gateway drops and never recovers. Error message as follows:

2018-06-14 01:05:19 ERROR (MainThread) [mysensors.gateway_tcp] No response from ('192.168.1.204', 5003). Disconnecting
2018-06-14 01:05:19 ERROR (MainThread) [homeassistant.core] Error doing job: Exception in callback AsyncTCPGateway._check_connection()
Traceback (most recent call last):
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/mysensors/gateway_tcp.py", line 144, in _check_connection
    super()._check_connection()
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/mysensors/gateway_tcp.py", line 35, in _check_connection
    self.server_address))
OSError: No response from ('192.168.1.204', 5003). Disconnecting

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3.5/asyncio/events.py", line 126, in _run
    self._callback(*self._args)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.5/site-packages/mysensors/gateway_tcp.py", line 147, in _check_connection
    self.protocol.transport.close()
AttributeError: 'NoneType' object has no attribute 'close'

If I access the gateway via MYSController after this error I see all the nodes responding properly to the gateway so I know the gateway is working properly.

Any ideas @martinhjelmare ?

Weā€™re investigating a fix here:

Any update on this? I have the same issue on 0.73.

Sorry, I havenā€™t had time to test my fix yet. Iā€™ll try to do that during this week.

The fixes in your PR seem to be working fine, after updating to 0.73 I was having issues again, swapping out to the PR version I havenā€™t had an error yet.

1 Like

Should be fixed in 0.74:

Iā€™m still experiencing disconnects in 0.74.2

If I stop HA and telnet to the gateway, connection is stable for hoursā€¦

What version of MySensors are you using?

Now you got me thinkingā€¦

I use two gateways both of them 2.2.0. Butā€¦ I only have disconnects in one of them which I believe that might have some sensor nodes in 2.1.0

Are you using a Pi as well?

Yes, and also for the gateways, one in port 5003 (the one that disconnects) and another in 5004.

Iā€™m using an Uno with a ethernet shield so I understand why mine was timing out, a Pi is like 1000000x faster shouldnā€™t be having issues really.

After a few more tests, and after enabling debug logging, iā€™ve found out that the gateway is not timing out, but somehow the responses of both gateways get mixed in a way that it only resets the timeout of one of the gateways. The other one times out and reconnectsā€¦
Donā€™t know if this scenario is not supported but it was working fine in 0.72.

May need @martinhjelmare to assist with this issue.

Interesting. Can you post the logs?

Sure I will, Iā€™ll be off for a couple of days and iā€™ll post them as soon as I get back.

1 Like

Hi @martinhjelmare,

Here are the logs: https://hastebin.com/ulewoyubud.cs

In the logs sensors with id 1xx belong to one gateway while sensors with id 2xx belong to the other.

Meanwhile Iā€™ve updated hass to 75.3 just to make sure i was on the lastest hass version. The behaviour is the sameā€¦

Similar problem here, 2 gateways, raspberry pi gateway and arduino uno with ethernet shield. All working ok on 0.73.2, all versions since to 0.75.3 home-assistant looses connection to uno which then resets, this repeats every minute. Remove raspberry pi gateway from configuration file all ok. have tested with 2 uno gateways and all ok. Nothing new to add to logs already submitted by friopes

Thanks everyone for the feedback and logs. I think Iā€™ve found the bug. Now Iā€™ll work on verifying it, a fix and testing. Iā€™ll update here when I have something to show.

1 Like

Thank you.

1 Like