Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve robustness of robot discovery and connection #265

Open
Orhideous opened this issue Feb 27, 2024 · 2 comments
Open

Improve robustness of robot discovery and connection #265

Orhideous opened this issue Feb 27, 2024 · 2 comments

Comments

@Orhideous
Copy link
Collaborator

Orhideous commented Feb 27, 2024

There are cases where missed packets and timeouts cause robot discovery to fail.
We need to improve logging and write some integration tests for the most common problems.

See: home-assistant/core#111634
See: home-assistant/core#111599

@kaueraal
Copy link

kaueraal commented May 7, 2024

Another data point for this: I am affected with a Roomba 960. I cannot pair it in Home Assistant, where I get errors like

ERROR (roombapy) [roombapy.remote_client] Can't connect to 10.17.40.21
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 93, in connect
    self._open_mqtt_connection()
  File "/usr/local/lib/python3.12/site-packages/roombapy/remote_client.py", line 121, in _open_mqtt_connection
    self.mqtt_client.reconnect()
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 1044, in reconnect
    sock = self._create_socket_connection()
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/paho/mqtt/client.py", line 3685, in _create_socket_connection
    return socket.create_connection(addr, timeout=self._connect_timeout, source_address=source)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/socket.py", line 852, in create_connection
     raise exceptions[0]
   File "/usr/local/lib/python3.12/socket.py", line 837, in create_connection
     sock.connect(sa)
 ConnectionRefusedError: [Errno 111] Connection refused
ERROR (roombapy) [roombapy.remote_client] Unable to connect to 10.17.40.21
WARNING (roombapy) [roombapy.roomba] Unexpectedly disconnected from Roomba 10.17.40.21, code The connection was lost
WARNING (roombapy) [roombapy.roomba] Periodic connection lost due to Unable to connect to Roomba at 10.17.40.21

which are similar/the same as in the linked issues.

When connecting directly via roombapy discover 10.17.40.21 or roombapy connect 10.17.40.21 -p XXXX I get in ~50% of the cases a TimeoutError: _ssl.c:975: The handshake operation timed out.

Increasing the timeout in getpassword.py via changing server_socket.settimeout(3) to server_socket.settimeout(30) allows me to connect each time in roombapy without problems. I can ping the Roomba usually with <10ms, but seldom I see spikes to 2000–3000ms. Maybe the Roomba's Wifi goes to sleep?

I used roombapy 1.8.1 installed via pip for the latter testing. As I'm running Home Assistant via Docker I cannot really test other values there.

@kaueraal
Copy link

kaueraal commented May 22, 2024

My comment above seems to be handled in #310 and #311 for getpassword.py. Similar work might be required for the remote client used e.g. in Home Assistant.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants