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

Uncaught thread exception #43388

Closed
gdiciancia opened this issue Nov 19, 2020 · 16 comments
Closed

Uncaught thread exception #43388

gdiciancia opened this issue Nov 19, 2020 · 16 comments

Comments

@gdiciancia
Copy link

gdiciancia commented Nov 19, 2020

The problem

Recurring error multiple times a minute showing up in the logs.

Environment

  • Home Assistant Core release with the issue: 118.0
  • Last working Home Assistant Core release (if known): 117.3
  • Operating environment (OS/Container/Supervised/Core): OS
  • Integration causing this issue: roomba
  • Link to integration documentation on our website:

Problem-relevant configuration.yaml

Traceback/Error logs


Logger: root
Source: /usr/src/homeassistant/homeassistant/bootstrap.py:318
First occurred: 12:03:37 PM (38 occurrences)
Last logged: 12:11:05 PM
Uncaught thread exception

Traceback (most recent call last):
  File "/usr/local/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/usr/local/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3452, in _thread_main
    self.loop_forever(retry_first_connection=True)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1779, in loop_forever
    rc = self.loop(timeout, max_packets)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1197, in loop
    rc = self.loop_write(max_packets)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 1598, in loop_write
    rc = self._packet_write()
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 2374, in _packet_write
    self._do_on_disconnect(0)
  File "/usr/local/lib/python3.8/site-packages/paho/mqtt/client.py", line 3360, in _do_on_disconnect
    self.on_disconnect(self, self._userdata, rc)
TypeError: _internal_on_disconnect() missing 1 required positional argument: 'rc'



Additional information

For MQTT I use:

  • Home Assistant Add-on: Mosquitto broker, version 5.1

This are the only custom things I have (I don't use HACS):

  • /local/community/auto-entities.js
  • /local/community/slider-entity-row.js
@gdiciancia
Copy link
Author

Edit: I removed below customization, the issue persists.
/local/community/auto-entities.js
/local/community/slider-entity-row.js

@elupus
Copy link
Contributor

elupus commented Nov 20, 2020

This is a reopen of: #41479 that seem to have been incorrectly closed.

@elupus
Copy link
Contributor

elupus commented Nov 20, 2020

This is a guess, but our signature for the on disconnect callback does not match v5 semantics here: https://github.com/eclipse/paho.mqtt.python/blob/5a9ca61a6c3071972caddf554490bf9ee5316491/src/paho/mqtt/client.py#L2027

We don't expect a properties parameter in our mqtt integrations here:

def _mqtt_on_disconnect(self, _mqttc, _userdata, result_code: int) -> None:

@elupus
Copy link
Contributor

elupus commented Nov 20, 2020

Ps. Still does not explain how the exception is logged.

I wonder if /usr/local is really where hassos installs deps.

@probot-home-assistant
Copy link

Hey there @home-assistant/core, @emontnemery, mind taking a look at this issue as its been labeled with an integration (mqtt) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@emontnemery
Copy link
Contributor

emontnemery commented Nov 20, 2020

Opening #41479 was my fault, we should not have rolled back PAHO MQTT to 1.5.0 and it was re-bumped back to 1.5.1 shortly after.

The link to paho code is not correct, Home Asssistant core pins v1.5.1, so this is the right version to link to: https://github.com/eclipse/paho.mqtt.python/blob/v1.5.1/src/paho/mqtt/client.py#L3360

The line numbers in the stack trace matches v.1.5.1precisely, so the issue shouldn't be Home Assistant picking up the wrong version of PAHO MQTT.

Our on_disconnect has the right signature for sure:

def _mqtt_on_disconnect(self, _mqttc, _userdata, result_code: int) -> None:

It's however not named _internal_on_disconnect. There's in fact no function _internal_on_disconnect neither in PAHO MQTT nor in Home Assistant.

@gdiciancia have you added some other customization or modification which is interfacing with MQTT?

@gdiciancia
Copy link
Author

@emontnemery, Not that we can think of. I use the standard mqtt add-on. If you can be more specific, I can look more in detail. I had either wemos connected via mqtt or 1 Shelly 3EM with auto discovery. No customization on Home assistant

@emontnemery
Copy link
Contributor

Try searching for any python file including _internal_on_disconnect

@elupus
Copy link
Contributor

elupus commented Nov 20, 2020

The signature is not really incorrect per say. It's just not compatible with v5 of mqtt: https://github.com/eclipse/paho.mqtt.python/blob/42f0b13001cb39aee97c2b60a3b4807314dfcb4d/src/paho/mqtt/client.py#L467

It can send an additional properties field. That said, i agree the error would seem to be from another version of paho.

@gdiciancia do you think you can uninstall (pip uninstall paho-mqtt) inside the home assistant core container. Then let restart home assistant so it reinstalls it as a dependency.

@gdiciancia
Copy link
Author

@elupus, I’ll give that a try a soon as possible

@emontnemery
Copy link
Contributor

@elupus Home Assistant is not using MQTT version 5, and as I mentioned before the callback is named _mqtt_on_disconnect, not _internal_on_disconnect.

Hence, try to find a python package interfacing PAHO, with a function named _internal_on_disconnect.

@gdiciancia
Copy link
Author

Found it. I'm using the Roomba integration (added via discovery).

This is what the search found:
Binary file /usr/local/lib/python3.8/site-packages/roomba/pycache/mqttclient.cpython-38.pyc matches
/usr/local/lib/python3.8/site-packages/roomba/mqttclient.py:63: mqtt_client.on_disconnect = self._internal_on_disconnect
/usr/local/lib/python3.8/site-packages/roomba/mqttclient.py:89: def _internal_on_disconnect(self, client, userdata, flags, rc):

@emontnemery
Copy link
Contributor

I opened a PR on roombapy to fix this.

@probot-home-assistant
Copy link

roomba documentation
roomba source
(message by IssueLinks)

@probot-home-assistant
Copy link

Hey there @pschmitt, @cyr-ius, @shenxn, mind taking a look at this issue as its been labeled with an integration (roomba) you are listed as a codeowner for? Thanks!
(message by CodeOwnersMention)

@emontnemery
Copy link
Contributor

This should be fixed by #43594 which bumps roombapy to 1.6.2 which includes pschmitt/roombapy#45

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

No branches or pull requests

4 participants