Commit Graph
44 Commits
Author SHA1 Message Date
Mathieu Carbou ea3ebd7289 Do not rely on configENABLE_BACKWARD_COMPATIBILITY 2024-04-20 11:14:17 +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 bf3e4d23f3 Rework CI and fix an error (#6) 2024-01-18 08:13:53 +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 fb0411b699 Adapt for LibreTuya compatibility (#3) 2022-08-09 17:34:14 +12: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
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 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
Matt 1a15dfd17f Add thread safety around choosing a closed_slot. 2019-09-24 19:00:02 +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 19a532064c Merge branch 'master' into fix-crash-on-fin-v2 2019-09-24 12:15:58 +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
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 9a4a58a0db Allow for multiple close events. 2019-09-23 19:44:46 +01:00
Me No Dev 882ef829d6 Merge branch 'master' into fix_dns 2019-09-22 22:40:10 +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
Thorsten von Eicken 5e2d35ee08 fix DNS not-found results 2019-08-30 21:28:02 -07:00
Bernhard Tittelbach b548abc97c fix ESPAsyncWebServer/issues/265 in AsyncTCP as well 2019-08-06 20:28:11 +02:00
obrain17 a924420b93 Fix Issue that connect() did not work with DNS
Add additional code to "bool AsyncClient::connect(const char* host, uint16_t port)" and "static void _handle_async_event(lwip_event_packet_t * e)".
Async Service task and queue had not yet been started and "LWIP_TCP_DNS" had no handler defined, so "_tcp_dns_found" called by "dns_gethostbyname" ran into an error.
2019-06-29 17:43:43 +02:00
Mike Dunston f9e107cc52 Update AsyncClient::errorToString for esp-lwip constants
fix #45 by switching from hardcoded values to use the esp-lwip err enum constants
2019-06-25 06:02:52 -07:00
me-no-dev 1ad1280623 Code cleanup and restructure 2019-06-24 13:20:23 +02:00
me-no-dev 4b20e84027 abort and close are called without client in the server code 2019-06-24 12:31:00 +02: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 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
tantive 29661a6308 Fixed "Guru Meditation Error: Core 1 panic'ed (LoadProhibited) . Exception was unhandled." (see https://github.com/espressif/esp-idf/issues/1467) 2019-01-03 20:40:57 +01: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 5453ec2e3f improve stability a bit more 2018-08-17 20:57:55 +02:00
me-no-dev 34a0320834 Connection close stability improvements
Should help with most of the exceptions that have been plaguing the ESP32 port
2018-08-16 22:19:50 +02:00
me-no-dev 2f76a9f5b6 fix case where connection is already freed 2018-07-24 21:09:37 +02:00
me-no-dev 42a3f3d8b8 Add support for single core mode 2018-07-09 21:49:40 +02:00
copercini 69235b7060 Put the task in blocking mode when there is no items in queue 2018-03-08 10:07:46 -03: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