home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
72.67k stars 30.42k forks source link

XMPP Warning und multiple Messages #28611

Closed Loader23 closed 4 years ago

Loader23 commented 4 years ago

Home Assistant release with the issue:

0.101.2

Last working Home Assistant release (if known): 0.100 but not really sure

Operating environment (Hass.io/Docker/Windows/etc.):

Docker Integration:

https://www.home-assistant.io/integrations/xmpp/

Description of problem: The Log says:

WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one.

On notifying I am getting 3 Messages instead of one. This was not the case with the earlier version.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant): Thats the automation.

    alias: ''
    data:
      filename: /config/www/cam_captures/door_{{now ().day }}.{{ now ().month }}.{{ now ().year }}_{{ now ().hour }}:{{ now ().minute }}.jpg
    entity_id: all
  - service: notify.notify
    data_template:
      title: ""
      message: ""
      data:
        path: /config/www/cam_captures/door_{{now ().day }}.{{ now ().month }}.{{ now ().year }}_{{ now ().hour }}:{{ now ().minute }}.jpg

Traceback (if applicable):

Additional information:

probot-home-assistant[bot] commented 4 years ago

Hey there @fabaff, @flowolf, mind taking a look at this issue as its been labeled with a integration (xmpp) you are listed as a codeowner for? Thanks!

thundergreen commented 4 years ago

My hass version is 101.3 and there the famous itaration error comes up again:

2019-11-10 21:52:32 ERROR (MainThread) [homeassistant.core] Error doing job: Fatal error: protocol.data_received() call failed.
Traceback (most recent call last):
  File "/usr/local/lib/python3.7/asyncio/selector_events.py", line 816, in _read_ready__data_received
    self._protocol.data_received(data)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 406, in data_received
    self._spawn_event(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 970, in _spawn_event
    stanza = self._build_stanza(xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/xmlstream.py", line 951, in _build_stanza
    stanza = stanza_type(self, xml)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1390, in __init__
    ElementBase.__init__(self, xml, parent)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 416, in __init__
    if self.setup(xml):
  File "/usr/local/lib/python3.7/site-packages/slixmpp/stanza/stream_features.py", line 27, in setup
    self.values = self.values
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 615, in _set_stanza_values
    self[full_interface] = value
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 753, in __setitem__
    lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 959, in _set_sub_text
    return self._del_sub(name, lang=lang)
  File "/usr/local/lib/python3.7/site-packages/slixmpp/xmlstream/stanzabase.py", line 1040, in _del_sub
    parent = self.xml.find(parent_path)
  File "/usr/local/lib/python3.7/xml/etree/ElementTree.py", line 299, in find
    return ElementPath.find(self, path, namespaces)
  File "/usr/local/lib/python3.7/xml/etree/ElementPath.py", line 307, in find
    return next(iterfind(elem, path, namespaces), None)
TypeError: 'NoneType' object is not an iterator
WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one.

This can be ignored i guess as it appeared already in previous versions of home assistant

but the famous iteration issue is still not really fixed. Someties xmpp work .. no idea of what this depends but motly it just throws the error above

Related issue was here https://github.com/home-assistant/home-assistant/issues/20860

Loader23 commented 4 years ago

With 101.3 I do not receive 3 Messages at once anymore. I do not have the iteration issue but instead i have this:

2019-11-10 19:38:58 ERROR (MainThread) [homeassistant.components.xmpp.notify] Upload error, could not send message <iq id="7284df45-2416-4bd4-8049-b29ade8e6a1a-3" to="xmpp.server" type="get"><query xmlns="http://jabber.org/protocol/disco#items" /></iq>
2019-11-10 19:39:18 ERROR (stream_worker) [homeassistant.core] Error doing job: Future exception was never retrieved
slixmpp.exceptions.IqTimeout: <iq id="7284df45-2416-4bd4-8049-b29ade8e6a1a-2" to="xmpp.server" type="get"><query xmlns="http://jabber.org/protocol/disco#info" /></iq>
Loader23 commented 4 years ago

I have added a delay of 1 second between the notifications, now everything is working as it should. So only the warning about using slower stringprep remains.

thundergreen commented 4 years ago

Negative here: sending a message via dev-service calls already fails with error above :/

fabaff commented 4 years ago

See https://lab.louiz.org/poezio/slixmpp/issues/3429 and https://github.com/poezio/slixmpp/pull/17

thundergreen commented 4 years ago

@fabaff but that can't be the "solution". Either homeassistant usses its own branch of slixmpp or tries to solve this issue. That error accours not with everybody and not in any case (depending of the setup of each individual)

Loader23 commented 4 years ago

With version 0.103 xmpp stopped working and I get the same errors thundergreen mentioned above. Downgraded to 0.102.3 and its working again but still get the messages twice sometimes. So what has changed from 0.102.3 to 0.103 that could cause this?

thundergreen commented 4 years ago

same here .. it stopped working again after upgrading to 103.0 . somtimes it takes several restarts of hass and it starts working again... i will wait a few days and see. but it's sad that nobody wants to clean up this component.

flowolf commented 4 years ago

I just upgraded to 0.103.3 and I don't see errors for XMPP. It seems to be a very odd error.

Also, as we are using an external library for xmpp, the fix should be made there. so please let the slixmpp community know that there are issues.

Loader23 commented 4 years ago

Just updated to 103.3 to test it but the error is still there. Back to 102.3 and its working again...

miezie commented 4 years ago

See https://lab.louiz.org/poezio/slixmpp/issues/3429 and poezio/slixmpp#17

I tried to use this solution with the component I use with xmpp (freeathome) and can confirm that this doesn't work :-(. My related issue: https://github.com/jheling/freeathome/issues/27

mariohock commented 4 years ago

I had the problem with the TypeError, as well in home-assistant 0.103. and in 0.104.. Before, XMPP worked fine. Applying the fix mentioned above works for me (https://lab.louiz.org/poezio/slixmpp/issues/3429 and poezio/slixmpp#17). However lxml was missing a .so file (and complained about it in the home-assistant log). After installing lxml systemwide (sudo apt install python3-lxml) XMPP notifications work again. Thanks for the pointers.

Loader23 commented 4 years ago

And how do include these fixes in Docker?

ehendrix23 commented 4 years ago

Also, as we are using an external library for xmpp, the fix should be made there. so please let the slixmpp community know that there are issues.

But the issue only seems to be happening when used within HA. When used outside of HA this issue does not exist. A change was done in HA (0.87) that broke this as before it worked fine and version for slixmpp was not changed. See https://github.com/home-assistant/home-assistant/issues/20860

thundergreen commented 4 years ago

I got it running again people!

I made follwing:

I created xmpp folder in custom_components/xmpp and added the files from github repo:

https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/xmpp

And voila it works!.. i saw that there was a change but dunno when and if this change has already been merged in 104.3 but it works without custom sleexmpp

good luck people!

mariohock commented 4 years ago

Here is another workaround:

I implemented a proof-of-concept app for Home-Assistant's AppDaemon that allows bidirectional XMPP communications. It can also work as a replacement for the notify/jabber service of Home-Assistant discussed above.

https://github.com/mariohock/Chatty

Advantages:

[Potential] Disadvantages:

thundergreen commented 4 years ago

@mariohock would you mind giving a bit more explanation how to use it? i just installed it. but dunno how to set it up and use it :P

mariohock commented 4 years ago

Sure. I answered the corresponding issue in: https://github.com/mariohock/Chatty/issues/1 with some instructions.

Loader23 commented 4 years ago

@thundergreen Thanks alot, I used the custom_components and its working again. It did not with 104.3 so the changes are not merged yet.

meisterlampe commented 4 years ago

To me it looks like the XMPP Component in the Dev Branch and the Branch of 104.3 are identical. (Actually they are identical starting from 104.0). So this is a bit strange.

thundergreen commented 4 years ago

Like I said ..I just pulled the files into my custom_component folder and it started working again ..let me know if it also works for you ..maybe then the devs might find the issue

meisterlampe notifications@github.com schrieb am Mo., 3. Feb. 2020, 12:30:

To me it looks like the XMPP Component in the Dev Branch https://github.com/home-assistant/home-assistant/tree/dev/homeassistant/components/xmpp and the Branch of 104.3 https://github.com/home-assistant/home-assistant/tree/0.104.3/homeassistant/components/xmpp are identical. (Actually they are identical starting from 104.0 https://github.com/home-assistant/home-assistant/tree/0.104.0/homeassistant/components/xmpp ). So this is a bit strange. But I will try that anyway :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/home-assistant/home-assistant/issues/28611?email_source=notifications&email_token=ADFUA765H3CZEMNQ3ZQPQ53RA755NA5CNFSM4JKG3LH2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEKTP2TQ#issuecomment-581369166, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFUA75TK6YWNZVACEGPV7LRA755NANCNFSM4JKG3LHQ .

mariohock commented 4 years ago

From the observed behaivor of the bug of the XMPP component, I guess there is some kind of race condition or similar. Therefore changing unrelated things (like putting the code in custom component) may affect whether it works or not. But it can also change back any time.

thundergreen commented 4 years ago

@mariohock just changed back and coomponent broken gain :P

ktpx commented 4 years ago

Same issue here. Broke recently, running latest 107.6.

thundergreen commented 4 years ago

@ktpx are u usind xmpp in custom_components? It works sometimes :) I had to restart hass several times and then it worked again

janteau commented 4 years ago

I can confirm that updating Home Assistant's slixmpp to match @jheling's pull request: https://github.com/poezio/slixmpp/pull/20 fixes the issue for me.

sanderlv commented 4 years ago

When will this natively be integrated and supported in HA?

There seems to be working on a fix: https://github.com/poezio/slixmpp/pull/20

thundergreen commented 4 years ago

Afaik the patch has been merged into slixmpp and once you update homeassistant it'll pull the new patch. I upgraded to beta release of home assistant and it seems finally fixed :)

ksya commented 4 years ago

I don't think home assistant will install the latest slixmpp version including the fix. The latest slixmpp version is from January last year (1.4.2).

To install the git version, you should do this (for hassio or docker):

The easiest is to open a ssh connection to your OS where hassio is installed, then execute: sudo docker exec -it homeassistant /bin/bash The other option is to install Portainer addon. Go to web UI. Then go to the homeassistant container Open console Execute pip install --upgrade git+https://lab.louiz.org/poezio/slixmpp.git Now it will build and install slixmpp from the repository

Restart Home Assistant.

janteau commented 4 years ago

To install the git version, you should do this (for hassio or docker):

The easiest is to open a ssh connection to your OS where hassio is installed, then execute: sudo docker exec -it homeassistant /bin/bash

Execute pip install --upgrade git+https://lab.louiz.org/poezio/slixmpp.git Now it will build and install slixmpp from the repository

Restart Home Assistant.

This resulted in slixmpp not working for me. I didn't receive any errors in the Home Assistant logs though.

I then had to pip uninstall slixmpp and pip install slixmpp, and then manually apply @jheling's changes again.

Loader23 commented 4 years ago

pip install --upgrade git+https://lab.louiz.org/poezio/slixmpp.git Is also not working for me. How do I manually apply the changes in docker?

janteau commented 4 years ago

pip install --upgrade git+https://lab.louiz.org/poezio/slixmpp.git Is also not working for me. How do I manually apply the changes in docker?

sudo docker exec -it homeassistant /bin/bash

cd /usr/local/lib/python3.7/site-packages/slixmpp/xmlstream

mv stanzabase.py stanzabase.py.old

wget https://raw.githubusercontent.com/jheling/slixmpp/9538811ced3e74523c1dd2c26c69f4e50db3adb2/slixmpp/xmlstream/stanzabase.py

cd /usr/local/lib/python3.7/site-packages/slixmpp/plugins/xep_0009/stanza

mv RPC.py RPC.py.old

wget https://raw.githubusercontent.com/jheling/slixmpp/9538811ced3e74523c1dd2c26c69f4e50db3adb2/slixmpp/plugins/xep_0009/stanza/RPC.py

Then restart Home Assistant. This does not update to the git version of slixmpp (@ksya's method should have done that) but makes the exact changes that @jheling did.

Loader23 commented 4 years ago

Thanks alot, its working now :-)

janteau commented 4 years ago

It's not a long term solution - every Home Assistant update will undo those changes. It should probably be investigated why the git version of slixmpp does not seem to work.

lordfiSh commented 4 years ago

any update on this?

thundergreen commented 4 years ago

@lordfiSh Should be fixed with latest slixmpp library.

Loader23 commented 4 years ago

Is the latest library included in current Docker Release? Iam still using the fix above.

lordfiSh commented 4 years ago

@thundergreen I know, but its not in Homeassistant yet, thats why I'm asking.

jorgwonline commented 2 years ago

Could it be that the related warning messages are back?

Logger: slixmpp.stringprep
Source: /usr/local/lib/python3.9/site-packages/slixmpp/stringprep.py:120
First occurred: 11:54:56 AM (1 occurrences)
Last logged: 11:54:56 AM

Using slower stringprep, consider compiling the faster cython/libidn one.
thundergreen commented 2 years ago

You can easily ignore this messages

jorgwonline @.***> schrieb am Mo., 27. Dez. 2021, 12:15:

Could it be that the related warning messages are back?

Logger: slixmpp.stringprep Source: /usr/local/lib/python3.9/site-packages/slixmpp/stringprep.py:120 First occurred: 11:54:56 AM (1 occurrences) Last logged: 11:54:56 AM

Using slower stringprep, consider compiling the faster cython/libidn one.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/28611#issuecomment-1001515491, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADFUA76USOQEWCQTEIPKFXDUTBDFTANCNFSM4JKG3LHQ . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

gravelfreeman commented 7 months ago

Unbelievable in 2024:

2024-03-04 17:25:27.326 WARNING (MainThread) [slixmpp.stringprep] Using slower stringprep, consider compiling the faster cython/libidn one.