Skip to content

Better fix for "ack timeout 4" client disconnects. - #1

Merged
glmnet merged 2 commits into
esphome:masterfrom
mmakaay:master
May 9, 2021
Merged

Better fix for "ack timeout 4" client disconnects.#1
glmnet merged 2 commits into
esphome:masterfrom
mmakaay:master

Conversation

@glmnet

@glmnet glmnet commented May 9, 2021

Copy link
Copy Markdown
Member

[Copied from https://github.com/OttoWinter/pull/5]

After my first attempt at fixing the client disconnects (#4) got merged
into AsyncTCP, it turned out that there was regression for some devices: the connection stability actually went down instead of up.

After a lot of debugging and discussion with @glmnet (some of the results can be found in the above pull request discussion), we came up with an improved fix for the disconnect issues.

Changed:

The code that checks for ACK timeouts has been simplified in such way, that only two timestamps are now used to determine if an ACK timeout has happened: the time of the last sent packet (this was already recorded), and the time of the last received ACK from the client (this has been added).

Using these timestamps, there is no more need for a separate field to keep track if we are waiting for an ACK or not _pcb_busy). Therefore, this field was completely removed from the code.

While I was at it, I renamed a few variables to make the code easier to read and more consistent.

Results:

I connected Home Assistant plus 8 OTA loggers at the same time, using very verbose logging output. This normally was an easy way to trigger the disconnect errors.

It turned out, this solution runs as solid for me, as when disabling the ACK timeout checks completely using AsyncClient::setAckTimeout(0) (meaning: no more disconnects).

Maurice Makaay added 2 commits May 5, 2021 23:56
After my first attempt at fixing the client disconnects
(OttoWinter#4) got merged
into AsyncTCP, it turned out that there was regression
for some devices: the connection stability actually went
down instead of up.

After a lot of debugging and discussion with @glmnet (some of
the results can be found in the above pull request discussion),
we came up with an improved fix for the disconnect issues.

**Changed:**

The code that checks for ACK timeouts has been simplified in
such way, that only two timestamps are now used to determine if
an ACK timeout has happened: the time of the last sent packet
(this was already recorded), and the time of the last received
ACK from the client (this has been added).

Using these timestamps, there is no more need for a separate field
to keep track if we are waiting for an ACK or not (`_pcb_busy`).
Therefore, this field was completely removed from the code.

While I was at it, I renamed a few variables to make the code
easier to read and more consistent.

**Results:**

I connected Home Assistant plus 8 OTA loggers at the same time,
using very verbose logging output. This normally was an easy way
to trigger the disconnect errors.

It turned out, this solution runs as solid for me, as when disabling
the ACK timeout checks completely
(using `AsyncClient::setAckTimeout(0)`).
@glmnet
glmnet merged commit bfcba1f into esphome:master May 9, 2021
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

Successfully merging this pull request may close these issues.

2 participants