Commit Graph
93 Commits
Author SHA1 Message Date
Jesse Hills dc64fedec0 Bump version to 2.0.1 2023-09-01 14:18:18 +12:00
Kuba Szczodrzyński c53368456f Rename LibreTuya to LibreTiny (#4) 2023-09-01 14:12:55 +12:00
Jesse Hills c043464129 Bump version to 2.0.0 2022-08-09 17:34:36 +12:00
Kuba Szczodrzyński fb0411b699 Adapt for LibreTuya compatibility (#3) 2022-08-09 17:34:14 +12:00
Guillermo Ruffino 7c767c3f6b Bump version to 1.2.2 2021-05-09 19:11:18 -03:00
Guillermo Ruffino bfcba1f344 Merge pull request #1 from mmakaay/master
Better fix for "ack timeout 4" client disconnects.
2021-05-09 19:10:19 -03:00
Maurice Makaay 18ac673e82 Define one_day var as a const. 2021-05-06 00:41:06 +02:00
Maurice Makaay 6f379678f0 Better fix for "ack timeout 4" client disconnects.
After my first attempt at fixing the client disconnects
(https://github.com/OttoWinter/AsyncTCP/pull/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)`).
2021-05-05 23:56:48 +02:00
Otto Winter f278522a59 Bump version to 1.2.1 2021-04-11 19:09:48 +02:00
Maurice MakaayandMaurice Makaay 030b747616 Fix race condition causing 'ack timeout 4' disconnects (#4)
The AsyncClient::send() methods sets a boolean to true after pushing
data over the TCP socket successfully using tcp_output(). It also sets
a timestamp to remember at what time the data was sent.

The AsyncClient::_sent() callback method reacts to ACKs coming from
the connected client. This method sets the boolean to false.

In the AsyncClient::_poll() method, a check is done to see if the
boolean is true ("I'm waiting for an ACK") and if the time at which
the data was sent is too long ago (5000 ms). If this is the case,
a connection issue with the connected client is assumed and the
connection is forcibly closed by the server.

The race condition is when these operations get mixed up, because
of multithreading behavior. The _sent() method can be called during
the execution of the send() method:

1. send() sends out data using tcp_output()
2. _sent() is called because an ACK is processed, sets boolean to false
3. send() continues and sets boolean to true + timestamp to "now"

After this, the data exchange with the client was successful. Data were
sent and the ACK was seen.
However, the boolean ended up as true, making the _poll() method think
that an ACK is still to be expected. As a result, 5000 ms later, the
connection is dropped.

This commit fixes the code by first registering that an ACK is
expected, before calling tcp_output(). This way, there is no race
condition when the ACK is processed right after that call.

Additionally, I changed the boolean to an integer counter value.
The server might send multiple messages to the client, resulting in
multiple expected ACKs. A boolean does not cover this situation.

Co-authored-by: Maurice Makaay <mmakaay1@xs4all.net>
2021-04-11 19:09:21 +02:00
Otto winter cfecaa3a1c Bump version to 1.2.0 2021-04-08 15:34:35 +02:00
Otto winter d2fec0cb7e Merge remote-tracking branch 'upstream/master' 2021-04-08 15:30:32 +02:00
Bob ca8ac5f919 Fix LoadProhibited (#73) 2019-10-17 10:08:59 +03:00
matt123p cacac8f871 Make sure the closed slot is always freed (#68)
* Tidy up and fix some edge cases.

* Make sure we always release a closed_slot.
2019-10-14 22:38:04 +03:00
Bob d27a12ace6 Fix assertion errors (#72)
* Fix assertion errors

* Add state check

* replace tabs with spaces
2019-10-14 22:25:27 +03:00
Otto Winter c18b7cafcc Create fallback xTaskCreateUniversal function 2019-10-14 12:46:51 +02:00
Otto Winter 5b1ef41e83 Create fork for esphome 2019-10-14 12:46:34 +02:00
me-no-dev 6a54164802 Update install-arduino-ide.sh 2019-10-02 20:01:46 +03:00
me-no-dev 03b7e35c85 bump version 2019-10-02 12:10:08 +03:00
Me No Dev 625784b055 Ci update (#70) 2019-10-02 11:51:39 +03:00
Me No Dev 512035d391 Merge pull request #67 from matt123p/fix-crash-on-fin-v2
Fix crash on fin v3
2019-09-25 08:14:50 +03:00
Me No Dev f6f5cb621d Merge branch 'master' into fix-crash-on-fin-v2 2019-09-24 22:37:04 +03:00
me-no-dev b96c4feae7 Update README.md 2019-09-24 22:32:18 +03:00
Matt 6b855a820e Merge branch 'master' into fix-crash-on-fin-v2 2019-09-24 19:01:12 +01:00
Matt 1a15dfd17f Add thread safety around choosing a closed_slot. 2019-09-24 19:00:02 +01:00
Me No Dev f3ed41a129 Merge pull request #66 from matt123p/fix-crash-on-fin-v2
Fix crash on fin attempt 2
2019-09-24 20:40:41 +03:00
Me No Dev 7d15cb4a52 Merge branch 'master' into fix-crash-on-fin-v2 2019-09-24 20:14:59 +03:00
Matt 86fa8c6a52 Merge remote-tracking branch 'upstream/master' 2019-09-24 17:45:53 +01:00
Matt 826c12e361 Merge branch 'fix-crash-on-fin-v2' 2019-09-24 17:45:34 +01:00
Matt 13361c8da6 Use the system defined parameter to set the size of the closed_slots buffer. 2019-09-24 17:43:40 +01:00
me-no-dev 7ab3540f66 Update README.md 2019-09-24 16:14:02 +03:00
Me No Dev 19a532064c Merge branch 'master' into fix-crash-on-fin-v2 2019-09-24 12:15:58 +03:00
Me No Dev 0f6a09cf48 Merge pull request #59 from btittelbach/master
fix ESPAsyncWebServer/issues/265 in AsyncTCP as well
2019-09-24 12:12:39 +03:00
Me No Dev 78a0cba868 Update AsyncTCP.cpp 2019-09-24 12:09:18 +03:00
Me No Dev c16449b92c Merge branch 'master' into master 2019-09-24 12:07:28 +03:00
Me No Dev 5f107e7450 Merge pull request #65 from Mattel/feature/add-cmakelists
Add CMakeLists.txt file
2019-09-24 12:04:13 +03:00
Matt b171a7b94d Merge branch 'fix-crash-on-fin-v2' 2019-09-23 20:11:01 +01:00
Matt 15356c3300 Fix closed_slots initialization. 2019-09-23 20:08:33 +01:00
Matt 95d6a0a562 Merge remote-tracking branch 'upstream/master' into fix-crash-on-fin-v2 2019-09-23 19:56:53 +01:00
Matt 08108c28d9 Merge remote-tracking branch 'upstream/master' 2019-09-23 19:56:40 +01:00
Robert Alfaro 70898594df Add CMakeLists.txt file for ESP-IDF 2019-09-23 11:50:31 -07:00
Matt 9a4a58a0db Allow for multiple close events. 2019-09-23 19:44:46 +01:00
Me No Dev 483672016c Merge pull request #61 from tve/fix_dns
fix DNS not-found results
2019-09-22 22:46:57 +03:00
Me No Dev 882ef829d6 Merge branch 'master' into fix_dns 2019-09-22 22:40:10 +03:00
Me No Dev 091802a2f3 Merge pull request #64 from matt123p/fix-crash-on-fin
Fix crash caused by a race condition when the _lwip_fin function is called
2019-09-22 22:38:57 +03:00
Matt 911414ee98 Revert "try to catch some edge cases between LwIP and Async tasks" and fix in a completely different way. 2019-09-22 20:02:13 +01:00
me-no-dev f8e97b4930 Create stale.yml 2019-09-21 15:45:17 +03:00
Me No Dev 94fb6f4e35 Merge pull request #63 from me-no-dev/enable-ci
Enable Github CI
2019-09-21 15:15:14 +03:00
me-no-dev c1dcba41d1 Trigger travis also 2019-09-21 15:09:58 +03:00
Me No Dev c5ca5aee4e Enable Github CI 2019-09-21 15:05:52 +03:00