Comments (12)
I see that you do have a lock in the open_connection function after all, but it doesn't seem to be very safe.
At the very least a check _reader/_writer (is_connected) is necessary.
Perhaps something like this
--- aiokef.py.github
+++ aiokef.py
@@ -250,21 +250,21 @@
return (self._reader, self._writer) != (None, None)
async def open_connection(self) -> None:
- if self.is_connected:
- if self._writer.is_closing(): # type: ignore
- _LOGGER.debug(
- "%s: Connection closing but did not disconnect", self.host
- )
- await self._disconnect()
- else:
- _LOGGER.debug("%s: Connection is still alive", self.host)
- return
retries = 0
while retries < _MAX_CONNECTION_RETRIES:
- _LOGGER.debug("%s: Opening connection", self.host)
-
try:
async with self._lock, timeout(_TIMEOUT):
+ if self.is_connected:
+ if self._writer.is_closing(): # type: ignore
+ _LOGGER.debug(
+ "%s: Connection closing but did not disconnect", self.host
+ )
+ await self._disconnect(use_lock=False)
+ else:
+ _LOGGER.debug("%s: Connection is still alive", self.host)
+ return
+
+ _LOGGER.debug("%s: Opening connection", self.host)
self._reader, self._writer = await asyncio.open_connection(
self.host, self.port, family=socket.AF_INET
)
With this change (and the 1 second KEEP ALIVE disconnect timeout), we go from this
2020-10-12 15:48:16 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker.get_mode', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b"G'\x80"
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b"R'\x81\x97\xca"
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:31 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 151
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-12 15:48:32 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G(\x80'
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R(\x81\x89\xd7'
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 137
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:33 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G)\x80'
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:34 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R)\x81\x86\x91'
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 134
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:35 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G*\x80'
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R*\x81\x84"'
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 132
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:36 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] Finished call to 'aiokef.aiokef._AsyncCommunicator.send_message' after 5.393(s), this was the 1st time calling it.
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] Retrying aiokef.aiokef._AsyncCommunicator.send_message in 1.0 seconds as it raised ConnectionRefusedError: Connection tries exceeded..
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] Finished call to 'aiokef.aiokef._AsyncCommunicator.send_message' after 5.401(s), this was the 1st time calling it.
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] Retrying aiokef.aiokef._AsyncCommunicator.send_message in 1.0 seconds as it raised ConnectionRefusedError: Connection tries exceeded..
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] Finished call to 'aiokef.aiokef._AsyncCommunicator.send_message' after 5.405(s), this was the 1st time calling it.
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] Retrying aiokef.aiokef._AsyncCommunicator.send_message in 1.0 seconds as it raised ConnectionRefusedError: Connection tries exceeded..
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-12 15:48:37 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 2nd time calling it.
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G+\x80'
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 2nd time calling it.
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 2nd time calling it.
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R+\x81\x86G'
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 134
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G,\x80'
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R,\x81\xaa\x95'
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 170
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G-\x80'
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R-\x81\x80('
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:38 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 128
2020-10-12 15:48:39 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-12 15:48:39 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:48:39 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-12 15:48:39 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
To this
2020-10-12 15:52:08 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker.get_mode', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker.get_volume_and_is_muted', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b"G'\x80"
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b"R'\x81\x97\xca"
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 151
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G(\x80'
2020-10-12 15:52:26 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R(\x81\x8a\xde'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 138
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G)\x80'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R)\x81\x86\x91'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 134
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G*\x80'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R*\x81\x84"'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 132
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G+\x80'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R+\x81\x86G'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 134
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G,\x80'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R,\x81\xaa\x95'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 170
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G-\x80'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R-\x81\x81/'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 129
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G%\x80'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R%\x81B9'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 66
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker.get_state', this is the 1st time calling it.
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G0\x80'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R0\x81Z\x13'
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:27 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 90
2020-10-12 15:52:28 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-12 15:52:28 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-12 15:52:28 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-12 15:52:28 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
from aiokef.
from aiokef.
20201006_kef_lost_contact_log.txt
from aiokef.
To be clear, the speakers will stay powered on, and I can play music. Spotify Connect can still stream to them, and the port 80 web interface works, even though the KEF Connect app and this aiokef integration are not able to connect.
Complete disconnect / reconnect of mains power is necessary to restore connection.
After a power cycle, connection is back.
2020-10-06 20:16:48 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-06 20:17:18 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-06 20:17:18 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-06 20:17:18 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker.get_volume_and_is_muted', this is the 1st time calling it.
2020-10-06 20:17:18 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-06 20:17:18 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-06 20:17:18 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G%\x80'
2020-10-06 20:17:18 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R%\x81<D'
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 60
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker.get_state', this is the 1st time calling it.
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Connection is still alive
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G0\x80'
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b'R0\x81\xda\x9a'
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-06 20:17:19 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 218
2020-10-06 20:17:20 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-06 20:17:20 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-06 20:17:20 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-06 20:17:20 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
from aiokef.
Today the issue triggered again, and again it's when aiokef triggers 7 connections, the periodic 1x get_mode and 6x _get_dsp, simultaneously.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker.get_mode', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef.AsyncKefSpeaker._get_dsp', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] Starting call to 'aiokef.aiokef._AsyncCommunicator.send_message', this is the 1st time calling it.
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b"G'\x80"
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Got reply, b"R'\x81\x96\xcd"
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Received: 150
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:45 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnected
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection successful
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G(\x80'
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Reading message
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] Finished call to 'aiokef.aiokef._AsyncCommunicator.send_message' after 1.567(s), this was the 1st time calling it.
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] Retrying aiokef.aiokef._AsyncCommunicator.send_message in 1.0 seconds as it raised UnboundLocalError: local variable 'data' referenced before assignment.
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Opening connection failed
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Writing message: b'G)\x80'
2020-10-07 15:08:46 ERROR (MainThread) [aiokef.aiokef] 10.0.1.36: Got an exception in writing
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiokef/aiokef.py", line 299, in _send_message
await self._writer.drain()
File "/usr/local/lib/python3.8/asyncio/streams.py", line 375, in drain
raise exc
File "/usr/local/lib/python3.8/site-packages/aiokef/aiokef.py", line 308, in _send_message
data = await self._reader.read(100)
File "/usr/local/lib/python3.8/asyncio/streams.py", line 684, in read
await self._wait_for_data('read')
File "/usr/local/lib/python3.8/asyncio/streams.py", line 517, in _wait_for_data
await self._waiter
File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 846, in _read_ready__data_received
data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: _disconnect called
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Cancelling the _disconnect_task
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] 10.0.1.36: Going to disconnect now
2020-10-07 15:08:46 ERROR (MainThread) [aiokef.aiokef] 10.0.1.36: Disconnecting raised
Traceback (most recent call last):
File "/usr/local/lib/python3.8/site-packages/aiokef/aiokef.py", line 327, in _disconnect
await self._writer.wait_closed()
File "/usr/local/lib/python3.8/asyncio/streams.py", line 359, in wait_closed
await self._protocol._get_close_waiter(self)
File "/usr/local/lib/python3.8/site-packages/aiokef/aiokef.py", line 299, in _send_message
await self._writer.drain()
File "/usr/local/lib/python3.8/asyncio/streams.py", line 375, in drain
raise exc
File "/usr/local/lib/python3.8/site-packages/aiokef/aiokef.py", line 308, in _send_message
data = await self._reader.read(100)
File "/usr/local/lib/python3.8/asyncio/streams.py", line 684, in read
await self._wait_for_data('read')
File "/usr/local/lib/python3.8/asyncio/streams.py", line 517, in _wait_for_data
await self._waiter
File "/usr/local/lib/python3.8/asyncio/selector_events.py", line 846, in _read_ready__data_received
data = self._sock.recv(self.max_size)
ConnectionResetError: [Errno 104] Connection reset by peer
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] Finished call to 'aiokef.aiokef._AsyncCommunicator.send_message' after 1.573(s), this was the 1st time calling it.
2020-10-07 15:08:46 DEBUG (MainThread) [aiokef.aiokef] Retrying aiokef.aiokef._AsyncCommunicator.send_message in 1.0 seconds as it raised ConnectionResetError: [Errno 104] Connection reset by peer.
from aiokef.
I am looking into the specific DSP settings right now. I can verify that when I disable all DSP settings updates, that the problem seems to disappear. I will keep you updated!
from aiokef.
I forgot to mention this but I believe I also did not experience this issue when I had my DSP-configure automations disabled.
I have a few examples of logs from good vs bad scenarios, and I suspect it is triggered by the multiple new connection attempts the hourly DSP setting refresh (DSP scan) when there are no active connection. The aiokef in my 0.115.6 installation is a bit older than the latest, where KEEP ALIVE is now 100 seconds. This connection reset scenario may be making the issue much more likely to trigger, so the longer KEEP ALIVE is probably a workaround at best.
Any good way to prevent spawning 7+ concurrent connection attempts which will each try to connect? Perhaps the lock should be in the open connection function, instead of the send message function?
(Removing logs from scenario I had already covered initially.)
from aiokef.
Looks like the KEF speakers only accept one connection at a time, but once in a while it accepts two ("Opening connection successful") before a message exchange is completed (send+receive) and that seems to be the case for both log examples I have where the control interface in the speakers crashes.
I reduced the DSP scan timer from 1 hour to 20 seconds, while keeping the 1 second KEEP ALIVE / disconnect timer.
Restarted Home Assistant, and the KEF LSX speakers were on and playing music and so should still have DSP settings applied from before. Will monitor to see what happens. So far, after almost half an hour, I seem to see a single "Opening connection successful" at a time, and no issues yet.
from aiokef.
Over a week and still going strong, not seen any loss of control interface connectivity (speakers Unavailable).
Not yet heard from KEF support, other than that they would forward this information to the relevant department.
from aiokef.
I think it has been solved 😇😄
from aiokef.
Looks mostly gone, yep!
There are still some more unsafe corner cases of potential race conditions which aren't handled securely in this async flow which could use some overhaul. Risk is quite low that they would trigger the same type of issue, but perhaps not impossible.
For example any time you write to a global variable related to the connection state when outside of your main semaphore lock (self._lock), just the same as when you read the state and then need to act on it within a lock, you run the risk of overwriting a successful connection state. I think this would mainly cause the aiokef integration to stop working (at least for a little while) as a temporary hiccup of state Unavailable.
Line 289 in 215be75
If I'm reading the flow correctly, the _disconnect task is a bit aggressive too, There's a 2 second timeout for receiving after sending a message in _send_message, but the disconnect task can trigger during this window since it has a 1 second timeout, and so can stand there "knocking on the door" to disconnect directly after a slow reply comes in. If then there's a connection waiting for the _lock to free up, this seems to cause some avoidable, albeit temporary, connection failures.
from aiokef.
Thanks! I might look into those suggestions sometime in the future. However, I will also accept a PR of course ;)
from aiokef.
Related Issues (13)
- test with new firmware HOT 1
- ping device when not supported
- CI failure because of pip HOT 1
- AttributeError: 'str' object has no attribute '_asdict'
- Separation of concerns: speaker and protocol
- Feature request: speaker discovery HOT 1
- fix CHANGELOG
- add doc-strings
- Kef LSX HOT 16
- fix PARALLEL UPDATES
- 20 minutes standby bug HOT 4
- Credit https://github.com/kraih/kefctl
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aiokef.