Commit Graph
27 Commits
Author SHA1 Message Date
Mathieu Carbou db8cfa1ee7 Add setKeepAlive() 2024-04-27 01:17:55 +02:00
Mathieu Carbou 46a1dce19f Set CONFIG_ASYNC_TCP_QUEUE_SIZE to 64 2024-04-27 01:17:55 +02:00
Mathieu Carbou 92628f1f4d Set CONFIG_ASYNC_TCP_PRIORITY to 10 2024-04-27 01:17:55 +02:00
Mathieu Carbou de284cc5cc Add CONFIG_ASYNC_TCP_QUEUE_SIZE 2024-04-27 01:17:55 +02:00
Mathieu Carbou 0227108fc4 Add CONFIG_ASYNC_TCP_PRIORITY 2024-04-27 01:17:55 +02:00
Mathieu Carbou aac8c67dae v3.0.2 2024-04-20 12:31:17 +02:00
Mathieu Carbou 755c8cb8e0 v3.0.1 2024-04-20 11:48:50 +02:00
Mathieu Carbou 70943fffbf v3.0.0 2024-04-19 23:33:28 +02:00
Mathieu Carbou c4cb7653fe Arduino 3 / ESP IDF 5 compatibility 2024-04-19 22:43:05 +02:00
Jimmy Hedman 2ae3787c71 Fixes libretiny (#10) 2024-02-19 08:08:25 +13:00
Jimmy Hedman 87d4daa4ab Make LIBRETINY compile (#9) 2024-01-22 18:31:54 +09:00
Jimmy HedmanandPaweł pidpawel Kozubal 42a8644bb2 IPv6 support added (#5)
Co-authored-by: Paweł pidpawel Kozubal <pawel.kozubal@husarnet.com>
2023-12-21 12:59:30 +09:00
Kuba Szczodrzyński c53368456f Rename LibreTuya to LibreTiny (#4) 2023-09-01 14:12:55 +12:00
Kuba Szczodrzyński fb0411b699 Adapt for LibreTuya compatibility (#3) 2022-08-09 17:34:14 +12: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
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
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
Matt 9a4a58a0db Allow for multiple close events. 2019-09-23 19:44:46 +01:00
me-no-dev 4e7d1c3a2d try to catch some edge cases between LwIP and Async tasks 2019-06-24 10:23:58 +02:00
me-no-dev 00d3009b0c Enable WDT inside Arduino and PIO 2019-06-23 08:49:38 +02:00
me-no-dev cefd9e46d1 Add options to select running core and to enable WDT for Async 2019-06-23 08:43:46 +02:00
me-no-dev c9df7cdda6 Restyle and up lib version 2019-06-22 16:00:34 +02:00
me-no-dev f1a801fe06 Attempt at fixing thenasty memory bug
Everything except some protected stuff now happens on LwIP thread (tcp API that is). Close and Accept logic has been adjusted. Fingers crossed...
2019-06-22 12:08:29 +02:00
me-no-dev 6fab7724ab Add changes to make compile succeed with the latest IDF 2018-09-06 23:42:16 +02:00
me-no-dev 75e2b15377 Add option to handle pbufs instead of buffers 2018-01-27 12:30:24 +01:00
me-no-dev a1a184a953 Do not go through API if already on LwIP thread 2017-10-13 10:37:57 +03:00
me-no-dev af729ac1e4 Initial Import 2017-09-08 13:07:27 +03:00