core: ESPHome UnhandledAPIConnectionError after 2023.10.4 on 32-bit systems using noise encryption
The problem
ESPHome device unavailable after updating today.
Looks like the error is Associated data too long. Max 2**32 bytes (UnhandledAPIConnectionError)
Errors in the logs:
Logger: aioesphomeapi.reconnect_logic
Source: /usr/local/lib/python3.11/site-packages/aioesphomeapi/reconnect_logic.py:146
First occurred: 17:33:50 (6 occurrences)
Last logged: 17:34:55
Can't connect to ESPHome API for airgradient-pro @ 192.168.18.7: Unexpected error while connecting to airgradient-pro @ 192.168.18.7: Associated data too long. Max 2**32 bytes (UnhandledAPIConnectionError)
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 374, in finish_connection
await self._connection.finish_connection(login=login)
File "aioesphomeapi/connection.py", line 564, in finish_connection
File "aioesphomeapi/connection.py", line 551, in aioesphomeapi.connection.APIConnection.finish_connection
File "aioesphomeapi/connection.py", line 552, in aioesphomeapi.connection.APIConnection.finish_connection
File "aioesphomeapi/connection.py", line 526, in _do_finish_connect
File "aioesphomeapi/connection.py", line 366, in _connect_init_frame_helper
File "aioesphomeapi/_frame_helper/noise.py", line 138, in perform_handshake
File "aioesphomeapi/_frame_helper/noise.py", line 179, in aioesphomeapi._frame_helper.noise.APINoiseFrameHelper._send_hello_handshake
File "/usr/local/lib/python3.11/site-packages/noise/connection.py", line 110, in write_message
result = self.noise_protocol.handshake_state.write_message(payload, buffer)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/noise/state.py", line 345, in write_message
message_buffer += self.symmetric_state.encrypt_and_hash(payload)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/noise/state.py", line 172, in encrypt_and_hash
ciphertext = self.cipher_state.encrypt_with_ad(self.h, plaintext)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/noise/state.py", line 55, in encrypt_with_ad
ciphertext = self.cipher.encrypt(self.k, self.n, ad, plaintext)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.11/site-packages/noise/backends/default/ciphers.py", line 10, in encrypt
return self.cipher.encrypt(nonce=self.format_nonce(n), data=plaintext, associated_data=ad)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "src/chacha20poly1305_reuseable/__init__.py", line 102, in chacha20poly1305_reuseable.ChaCha20Poly1305Reusable.encrypt
File "src/chacha20poly1305_reuseable/__init__.py", line 128, in chacha20poly1305_reuseable.ChaCha20Poly1305Reusable.encrypt
OverflowError: Associated data too long. Max 2**32 bytes
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/reconnect_logic.py", line 173, in _try_connect
await self._cli.finish_connection(login=True)
File "/usr/local/lib/python3.11/site-packages/aioesphomeapi/client.py", line 380, in finish_connection
raise UnhandledAPIConnectionError(
aioesphomeapi.core.UnhandledAPIConnectionError: Unexpected error while connecting to airgradient-pro @ 192.168.18.7: Associated data too long. Max 2**32 bytes
What version of Home Assistant Core has the issue?
core-2023.10.4
What was the last working version of Home Assistant Core?
core-2023.10.3
What type of installation are you running?
Home Assistant Core
Integration causing the issue
ESPHome
Link to integration documentation on our website
No response
Diagnostics information
No response
Example YAML snippet
No response
Anything in the logs that might be useful for us?
No response
Additional information
No response
About this issue
- Original URL
- State: closed
- Created 8 months ago
- Comments: 29 (18 by maintainers)
The wheels are up and can be installed using the community ssh addon with protected mode disable by running:
Than restart
Ok so likely a 32bit problem
Either way the new improved error reporting in aioesphomeapi works great as it really helped to identify the issue quickly
Pleasantly surprised. I have no more issues to report
I’d open a new issue for that as its doesn’t seem related
New build to follow since the first one got canceled https://github.com/home-assistant/core/actions/runs/6598698115
HA wheels are building here https://github.com/home-assistant/core/actions/runs/6598661986
I’ll give you a command to update once its done.
In the mean time, please install the community ssh addon, as you’ll need to be able to access the container without protection mode turned on to update the library
https://github.com/bdraco/chacha20poly1305-reuseable/actions/runs/6598620732/job/17926787396 is building with a prospective fix.
I’ll get some wheels up for HA shortly so you can try installing them in your container