Giter Site home page Giter Site logo

espasynctcp's Introduction

ESPAsyncTCP

Build Status

Async TCP Library for ESP8266 Arduino

For ESP32 look HERE

Join the chat at https://gitter.im/me-no-dev/ESPAsyncWebServer

This is a fully asynchronous TCP library, aimed at enabling trouble-free, multi-connection network environment for Espressif's ESP8266 MCUs.

This library is the base for ESPAsyncWebServer

AsyncClient and AsyncServer

The base classes on which everything else is built. They expose all possible scenarios, but are really raw and require more skills to use.

AsyncPrinter

This class can be used to send data like any other Print interface (Serial for example). The object then can be used outside of the Async callbacks (the loop) and receive asynchronously data using onData. The object can be checked if the underlying AsyncClientis connected, or hook to the onDisconnect callback.

AsyncTCPbuffer

This class is really similar to the AsyncPrinter, but it differs in the fact that it can buffer some of the incoming data.

SyncClient

It is exactly what it sounds like. This is a standard, blocking TCP Client, similar to the one included in ESP8266WiFi

Libraries and projects that use AsyncTCP

espasynctcp's People

Contributors

adam5wu avatar andig avatar iman4k avatar ivankravets avatar links2004 avatar lobradov avatar me-no-dev avatar mhightower83 avatar michalfapso avatar palatis avatar roman3349 avatar xoseperez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

espasynctcp's Issues

Compile Errors after update of ESPAsyncTCP

Everything was working great then the library was updated in PlatformIO and I'm now getting the following errors.

Please advise.

.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o):(.bss.default_private_key+0x0): multiple definition of `default_private_key'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):(.bss.default_private_key+0x0): first defined here
.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o):(.bss.default_private_key_len+0x0): multiple definition of `default_private_key_len'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):(.bss.default_private_key_len+0x0): first defined here
/Users/jjohnston/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: Warning: size of symbol `default_private_key_len' change
d from 2 in .pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o) to 4 in .pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o)
.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o):(.bss.default_certificate+0x0): multiple definition of `default_certificate'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):(.bss.default_certificate+0x0): first defined here
.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o):(.bss.default_certificate_len+0x0): multiple definition of `default_certificate_len'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):(.bss.default_certificate_len+0x0): first defined here
/Users/jjohnston/.platformio/packages/toolchain-xtensa/bin/../lib/gcc/xtensa-lx106-elf/4.8.2/../../../../xtensa-lx106-elf/bin/ld: Warning: size of symbol `default_certificate_len' change
d from 2 in .pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o) to 4 in .pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o)
.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o): In function `ax_port_read':
WiFiClientSecure.cpp:(.text.ax_port_read+0x14): multiple definition of `ax_port_read'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):tcp_axtls.c:(.text.ax_port_read+0x14): first defined here
.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o): In function `ax_port_write':
WiFiClientSecure.cpp:(.text.ax_port_write+0x1c): multiple definition of `ax_port_write'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):tcp_axtls.c:(.text.ax_port_write+0xc): first defined here
.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o): In function `ax_get_file':
WiFiClientSecure.cpp:(.text.ax_get_file+0x0): multiple definition of `ax_get_file'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):tcp_axtls.c:(.text.ax_get_file+0x8): first defined here
.pioenvs/d1_mini/libESP8266WiFi.a(WiFiClientSecure.o): In function `ax_wdt_feed':
WiFiClientSecure.cpp:(.text.ax_wdt_feed+0x8): multiple definition of `ax_wdt_feed'
.pioenvs/d1_mini/libESPAsyncTCP_ID305.a(tcp_axtls.o):tcp_axtls.c:(.text.ax_wdt_feed+0x0): first defined here
collect2: error: ld returned 1 exit status
scons: *** [.pioenvs/d1_mini/firmware.elf] Error 1

SSL support

Pretty sure this is already on the roadmap, but this is obviously a needed feature. Keep up the good work!

Async SSL/TLS client

Hi,
I want to use the AsyncClient in combination with SSL/TLS.

Is there an example for this, or do i have to do anything else than define ASYNC_TCP_SSL_ENABLED and set secure = true at the connect method?

Thanks in advance,
Markus

Out of bound copy in ax_port_read()

In ax_port_read() there is a possibility to write out of the bounds of read_buf buffer.
pbuf_copy_partial() can write up to len and this value can be bigger then allocated memory.
Please fix this.

Adapting my code from regular WifiClient to AsyncClient

Hello, everyone!

I'm working on a project that needs a non-blocking connect() function to use in a ESP8266 working as a wifi client.

Every program cycle, my ESP reads some analog data from a matrix of sensors. Whenever the matrix remains "calm" (with no changes on the sensors) for at least 2 seconds, the ESP will connect to the wifi server and send its accumulated data.
The problem is that the WifiClient.connect() function takes up to 5 seconds trying to reach the server. During the connection process, I can lose critical reading from my sensors matrix. I need this time to be shorter.

Following the advise of @me-no-dev, I am adapting my code to the ESPAsyncTCP library. However, the present examples in the Issues section do not explain the "use" of the "non-blocking feature" of AsyncClient and/or AsyncPrinter clearly (or so I think).
I am a newcomer to these type of projects and the lack of documentation in the ESP8266 github libraries doesn't help much either.
For example, what's the equivalent function for WifiClient.available() in the AsyncClient class? How do you poll the client's buffer?

Anyway, I am looking for some example or documentation that explains the differences between the "Sync" and the "Async" modes of WiFi communication from the client's point of view.

Any help will be appreciated. Thank you so much!

Async client disconnects

Hi.

I am using Async client to connect to philips hue bridge in order to send asynchornously PUT json messages to hue bridge so that i can change hue status and color.

Async client connects to hue bridge and after a few seconds it disconnects (onDisconnect is triggered).

What can i do?

delay(xxx) causes crash while tcp_write()

Hi,

on any example that uses a read/write context simply put a delay(xxx) in the loop() function and the skatch will crash.

What other delay function would be safe?

Best,
M

Unable to contact server over http after enabling SSL for MQTT

I recently changed my code to use the Async libraries and am exceptionally happy with the results. My sensors are much more stable and don't give me much trouble at all.

I have a problem with a http request that is used for OTA updates.

My web server has two different certificates. One for the web site (HTTPS) which is renewed every year, and one for MQTTs which is renewed less frequently. (This means different fingerprints)

My sensors connect to the MQTT broker using SSL, and this is working fine.
The problem I have is that the location on the server for the OTA updates is setup for HTTP only, not HTTPS, and even if it was HTTPS the certificate fingerprint would not match because MQTT is using a different certificate.

Using non Async libraries this has been working well for many months, but now that I changed to using the Async libraries I get the result Error (-1): HTTP error: connection refused when the sensor performs a firmware update check. I can only assume that it is trying to connect using HTTPS, and not plain HTTP.

The address passed to the httpUpdate call is http://servername.com/firmware/sensormodel/checkfirmware.php

I guess what I am asking, is how to send a HTTP request even though I have SSL enabled?

Thanks in advance.

File loads only partially

I'm using the async webbrowser to load a file in the webbrowser. This works well when using chrome version 52 on a desktop PC. However using chrome (v52) on an android phone will only partly load the file and show a timeout in the logging. The problem seems to occur with any file over about 2k, but only on my telephone.

The logging that I've captured can be found below:

del if1
usl
mode : sta(5c:cf:7f:17:5d:98)
add if0
sta config unchangedf r0, scandone
no ******* found, reconnect after 1s
wifi evt: 1
STA disconnect: 201
reconnect
f 0, scandone
no ******* found, reconnect after 1s
wifi evt: 1
STA disconnect: 201
reconnect
f -180, scandone
no ******* found, reconnect after 1s
wifi evt: 1
STA disconnect: 201
STA: Failed!
reconnect
f r0, scandone
del if0
usl
mode : softAP(5e:cf:7f:17:5d:98)
add if1
dhcp server start:(ip:192.168.4.1,mask:255.255.255.0,gw:192.168.4.1)
bcn 100
[APConfig] local_ip: 192.168.4.1 gateway: 192.168.4.1 subnet: 255.255.255.0
[APConfig] DHCP IP start: 192.168.4.100
[APConfig] DHCP IP end: 192.168.4.200
[AP] softap config unchanged
OTA server at: esp8266-175d98.local:8266
SPIFFSImpl: allocating 512+180+1400=2092 bytes
SPIFFSImpl: mounting fs @100000, size=2fb000, block=2000, page=100
SPIFFSImpl: mount rc=0

wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
add 1
aid 1
station: 24:df:6a:53:34:ba join, AID = 1
wifi evt: 5
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
wifi evt: 7
TIMEOUT: 5142, state: Established
SPIFFS_close: fd=1
SPIFFS_close: fd=1
wifi evt: 7
wifi evt: 7
wifi evt: 7

AsyncClient: _poll before _rcv causes false timeout

_poll can be called from stack before _rcv,
cause _rx_last_packet is initialized to 0 in constructor
_poll will trigger the timeout instantly.

this happens frequently in my setup since WebServer sets timeout.
me-no-dev/ESPAsyncWebServer@d935b1d

initializing _rx_last_packet to millis() in constructor solves the problem for me,
but I'm not sure if this is the best solution for the issue.

Cannot reconnect after disconnecting

I have a following piece of code (shortened, some functions are missing):

SyncClient socket;

void connect_to_ap(const char* ssid, const char* password) {
  if (WiFi.status() == WL_CONNECTED)
    return;
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(200);
  }
}

bool connect_to_server() {
  while(!socket.connect(server, port)) {
    if (WiFi.status() != WL_CONNECTED)
      return false;
    delay(50);
  }
  return true;
}

void setup() {
  while(true) { 
    Serial.begin(115200);
    init_gpio();
    connect_to_ap(NET_SSID, NET_PASSWORD);
    setup_ota();
    Serial.print("Connecting to server... ");
    if (!connect_to_server()) {
      Serial.println("failed");
      continue;
    }
    Serial.println("succeeded");
    break;
  } 
}

void loop() {
  ArduinoOTA.handle();
  yield();
  if (!socket.connected())
    setup();

  // Do some work
}

Basically, it should connect to WiFi, connect to server and restore the connection, when lost. The first connection is Ok, however when the server closes the connection and socket.connect(server, port) is called for the second time, it never returns (even the server starts accepting new connections). Calling socket.stop() does not help, creating new SyncClient via socket = SyncClient() causes crash.

I think this is not the expected behavior and it is a probably a bug in the library (if I am not doing anything wrong).

Compatibility with 2.3.0 esp8266/Arduino

when enabled ssl option in your config
#define ASYNC_TCP_SSL_ENABLED 1
appears compilation error for duplication your tcp_axtls.c with arduino WiFiClientSecure.cpp
like ax_port_write and others functions/variables

Using 2 ESPAsyncTCP Servers causing unexpected out-of-order sequence

ESPAsyncTCP and ESPAsyncWebServer are two very useful libraries! I'm working on some implementations and have ran into some questions

@me-no-dev
A similar issue as #44 I'm experiencing when using 2 ESPAsyncTCP Servers (1 for control, 1 for data). The protocol (FTP) requires action on both clients:
ie 'MLSD' command received on control client [1], requires a response '150' being send on the control client [2], a directory listing to be sent on data client [3] and process termination by replying summary report via control client [4].
When trying to do this from the control.onData() function, the actual sending will be [1][2][4][3], causing the FTP sequence to fail. It seems that all action towards the data client are executed after control.onData() has finished.
Question 1: Is this intended behaviour?
Also processing control.onData() seems to block data.onClient()
Question 2: Is this intended behaviour?

Using a Handler() function in loop() is off course an option, but creating servers without the need of handlers was the beauty of Async implementation. ;-)

As alternative I found that using control.onPoll() can be used as synchronisation trigger. Setting a kind of callback and a selectable number of polls to wait and to make sure there is no overlap with control.onData() seems to work fine. In control.onData() the callback is enabled after the command is recognized [1a] and the control.onData() function is ended [1b]. On one of the next control.onPoll() events, the sequence [2][3][4] (numbers as before) is completed in order.
Question 3: Do you foresee any issues using onPoll() this way?

Thanks.

Publish the library on PlatformIO

Would you mind publishing this awesome library to PlatformIO? I am currently working on an async MQTT client, and it would be handy not having to download the dependency manually. Thanks!

ESPAsyncTCPServer example needed

I can't figure out how to code a simple multi client async TCP server using your library. I've looked at the WebServer code and can't figure it out. An example similar to the ESP8266 Arduino Telnet Server would be very helpful!

rx timeout in ms

Hi, I would suggest to have rx timeout expressed in ms instead of seconds. To be able to set a timeout lower than 1 sec, I'm currently forced to implement externally.
Thanks

Example for the AsyncPrinter

Hi,

Thank you for your work on this library, it is very usefull.

Do you have any example about using the AsyncPrinter?

Best regards

Richard

ASYNC_TCP_SSL_ENABLED to 1 cause multiple definition error

This likely to be known problem for you: After changing the default of ASYNC_TCP_SSL_ENABLED to 1 in config.h, with the master version of espAsyncTCP and eSP8266WiFi, i got a problem with multiple definition of `ax_port_read' similar to this issue.

Given disable is the default and SSL support is open ticket, is that mean TLS server is not ready even if it is synchronous? Or, how do i fix this multiple definition error ?

httpclient

someone is aware if there is any httpclient impls that use asynctcp?

Now can't build with Core 2.3.0?

Just started trying to use this library yesterday, and I'm thinking your fixes to support 2.4.0 might have broken support for 2.3.0?

I really don't want to upgrade to 2.4.0 before it's had a chance to bleed a bit...

...I guess I will try to download the prior version of your library, but figured I should mention this first.

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp: In constructor 'AsyncClient::AsyncClient(tcp_pcb*)':

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:77:28: error: invalid conversion from 'long int (*)(void*, tcp_pcb*, pbuf*, long int)' to 'tcp_recv_fn {aka signed char (*)(void*, tcp_pcb*, pbuf*, signed char)}' [-fpermissive]

     tcp_recv(_pcb, &_s_recv);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:318:18: error:   initializing argument 2 of 'void tcp_recv(tcp_pcb*, tcp_recv_fn)' [-fpermissive]

 void             tcp_recv    (struct tcp_pcb *pcb, tcp_recv_fn recv) ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:78:28: error: invalid conversion from 'long int (*)(void*, tcp_pcb*, uint16_t) {aka long int (*)(void*, tcp_pcb*, short unsigned int)}' to 'tcp_sent_fn {aka signed char (*)(void*, tcp_pcb*, short unsigned int)}' [-fpermissive]

     tcp_sent(_pcb, &_s_sent);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:319:18: error:   initializing argument 2 of 'void tcp_sent(tcp_pcb*, tcp_sent_fn)' [-fpermissive]

 void             tcp_sent    (struct tcp_pcb *pcb, tcp_sent_fn sent)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:79:28: error: invalid conversion from 'void (*)(void*, long int)' to 'tcp_err_fn {aka void (*)(void*, signed char)}' [-fpermissive]

     tcp_err(_pcb, &_s_error);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:321:18: error:   initializing argument 2 of 'void tcp_err(tcp_pcb*, tcp_err_fn)' [-fpermissive]

 void             tcp_err     (struct tcp_pcb *pcb, tcp_err_fn err)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:80:31: error: invalid conversion from 'long int (*)(void*, tcp_pcb*)' to 'tcp_poll_fn {aka signed char (*)(void*, tcp_pcb*)}' [-fpermissive]

     tcp_poll(_pcb, &_s_poll, 1);

                               ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:320:18: error:   initializing argument 2 of 'void tcp_poll(tcp_pcb*, tcp_poll_fn, u8_t)' [-fpermissive]

 void             tcp_poll    (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp: In member function 'bool AsyncClient::connect(IPAddress, uint16_t)':

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:128:25: error: invalid conversion from 'void (*)(void*, long int)' to 'tcp_err_fn {aka void (*)(void*, signed char)}' [-fpermissive]

   tcp_err(pcb, &_s_error);

                         ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:321:18: error:   initializing argument 2 of 'void tcp_err(tcp_pcb*, tcp_err_fn)' [-fpermissive]

 void             tcp_err     (struct tcp_pcb *pcb, tcp_err_fn err)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp: In member function 'AsyncClient& AsyncClient::operator=(const AsyncClient&)':

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:166:28: error: invalid conversion from 'long int (*)(void*, tcp_pcb*, pbuf*, long int)' to 'tcp_recv_fn {aka signed char (*)(void*, tcp_pcb*, pbuf*, signed char)}' [-fpermissive]

     tcp_recv(_pcb, &_s_recv);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:318:18: error:   initializing argument 2 of 'void tcp_recv(tcp_pcb*, tcp_recv_fn)' [-fpermissive]

 void             tcp_recv    (struct tcp_pcb *pcb, tcp_recv_fn recv) ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:167:28: error: invalid conversion from 'long int (*)(void*, tcp_pcb*, uint16_t) {aka long int (*)(void*, tcp_pcb*, short unsigned int)}' to 'tcp_sent_fn {aka signed char (*)(void*, tcp_pcb*, short unsigned int)}' [-fpermissive]

     tcp_sent(_pcb, &_s_sent);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:319:18: error:   initializing argument 2 of 'void tcp_sent(tcp_pcb*, tcp_sent_fn)' [-fpermissive]

 void             tcp_sent    (struct tcp_pcb *pcb, tcp_sent_fn sent)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:168:28: error: invalid conversion from 'void (*)(void*, long int)' to 'tcp_err_fn {aka void (*)(void*, signed char)}' [-fpermissive]

     tcp_err(_pcb, &_s_error);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:321:18: error:   initializing argument 2 of 'void tcp_err(tcp_pcb*, tcp_err_fn)' [-fpermissive]

 void             tcp_err     (struct tcp_pcb *pcb, tcp_err_fn err)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:169:31: error: invalid conversion from 'long int (*)(void*, tcp_pcb*)' to 'tcp_poll_fn {aka signed char (*)(void*, tcp_pcb*)}' [-fpermissive]

     tcp_poll(_pcb, &_s_poll, 1);

                               ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:320:18: error:   initializing argument 2 of 'void tcp_poll(tcp_pcb*, tcp_poll_fn, u8_t)' [-fpermissive]

 void             tcp_poll    (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp: In member function 'long int AsyncClient::_connected(void*, long int)':

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:290:28: error: invalid conversion from 'long int (*)(void*, tcp_pcb*, pbuf*, long int)' to 'tcp_recv_fn {aka signed char (*)(void*, tcp_pcb*, pbuf*, signed char)}' [-fpermissive]

     tcp_recv(_pcb, &_s_recv);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:318:18: error:   initializing argument 2 of 'void tcp_recv(tcp_pcb*, tcp_recv_fn)' [-fpermissive]

 void             tcp_recv    (struct tcp_pcb *pcb, tcp_recv_fn recv) ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:291:28: error: invalid conversion from 'long int (*)(void*, tcp_pcb*, uint16_t) {aka long int (*)(void*, tcp_pcb*, short unsigned int)}' to 'tcp_sent_fn {aka signed char (*)(void*, tcp_pcb*, short unsigned int)}' [-fpermissive]

     tcp_sent(_pcb, &_s_sent);

                            ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:319:18: error:   initializing argument 2 of 'void tcp_sent(tcp_pcb*, tcp_sent_fn)' [-fpermissive]

 void             tcp_sent    (struct tcp_pcb *pcb, tcp_sent_fn sent)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:292:31: error: invalid conversion from 'long int (*)(void*, tcp_pcb*)' to 'tcp_poll_fn {aka signed char (*)(void*, tcp_pcb*)}' [-fpermissive]

     tcp_poll(_pcb, &_s_poll, 1);

                               ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:320:18: error:   initializing argument 2 of 'void tcp_poll(tcp_pcb*, tcp_poll_fn, u8_t)' [-fpermissive]

 void             tcp_poll    (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)ICACHE_FLASH_ATTR;

                  ^

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp: In member function 'void AsyncServer::begin()':

D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:839:30: error: invalid conversion from 'long int (*)(void*, tcp_pcb*, long int)' to 'tcp_accept_fn {aka signed char (*)(void*, tcp_pcb*, signed char)}' [-fpermissive]

   tcp_accept(_pcb, &_s_accept);

                              ^

In file included from D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:27:0:

C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0/tools/sdk/lwip/include/lwip/tcp.h:317:18: error:   initializing argument 2 of 'void tcp_accept(tcp_pcb*, tcp_accept_fn)' [-fpermissive]

 void             tcp_accept  (struct tcp_pcb *pcb, tcp_accept_fn accept) ICACHE_FLASH_ATTR;

                  ^

Using library ESP8266WiFi at version 1.0 in folder: C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266WiFi 
Using library ESP8266HTTPClient at version 1.1 in folder: C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\ESP8266HTTPClient 
Using library ESPAsyncTCP-master at version 1.1.0 in folder: D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncTCP-master 
Using library ESPAsyncWebServer-master at version 1.1.0 in folder: D:\Users\MyUser\Documents\Arduino\libraries\ESPAsyncWebServer-master 
Using library Ticker at version 1.0 in folder: C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\Ticker 
Using library EEPROM at version 1.0 in folder: C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\EEPROM 
Using library Hash at version 1.0 in folder: C:\Users\MyUser\AppData\Local\Arduino15\packages\esp8266\hardware\esp8266\2.3.0\libraries\Hash 
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).

SyncClient example with SSL fingerprint check

Hello

I really like your projects. I was able to start SSL using AsyncWebServer and I'm really impressed - finally my local connections are secured as they should. What I'm really missing is AsyncClient with SSL example. Checking certificate fingerprint (like WiFiClientSecure from esp8266/arduino) whould be more than enough.

send on WiFiClient in AsyncClient OnData problem!

Hello,

thanks for this library. Seems a step towards the right direction as the performance is really bad without it. However, I have trouble getting to run the function in a right way.

Scenario: I have a async client connection and a normal WiFiclient connection and want to send data received from the async client through the WiFiclient.

I have a strange behavior when sending data through WiFiClient.
I receive data from a callback function onData() and send the data through a WiFiclient socket.

    client->onData([](void *arg, AsyncClient *c, void *data, size_t len) {
        Serial.print("async_recv(): onData len = %d\n", len);
        if ( send_sock(&wifi_client, (const uint8_t *)data, len) != len )
        {
           Serial.print("async_recv(): onData send failed\n");
        }
    }, NULL);

The client->write function returns before hand, see blow:

send_sock(): -->
:wr
:ww
send_sock(): FAILED: send 0 of amount of 420 bytes. connected 1. available 0
_send_sock(): 0 <--_
**:sent 420**

thus, the function returns 0 written bytes as a return code, and the kernel does acknowledge the ":send 420"
at a later point. Here an example of a successful send in sync:

send_sock(): -->
:wr
**:sent 10**
:ww
_send_sock(): 10 <--_

What could cause this behavior?

Best
M

AsyncClient example needed

I'm trying to implement your AsyncClient non-blocking version of this library. Do you have an implementation example of this library ? i found the code but found no implementation example

This is the Scenario/issue I have which I hope your library will help me with :
Several sensors (atmega328 with NRF24L01) send data to one ESP8266 with NRF24L01 every around 2 secs
The sensors just send the data to the ESP8266, they don't wait for it to be available or wait for a confirmation from it, they just send the data.
The ESP8266 takes all the data received and places it in a queue.
Every 1 min approx the ESP8266 connects to a server and empties queue by posting all the data to the server.
While it posts the data, it won't listen the sensors so I will be missing some of the info.

using Async connection for a Server - Clinets connection

hi @me-no-dev sorry to make the issue for my question , actually I've planned to set module as AP and other module as Station mode and like IOT home , the server received and send command to those , Iggre told me I should use your lib instead of Esp8266WebServer lib , I really appreciated if you could guide me to what strategy should follow

Build failed on Arduino 2.4.0-rc2

When updating to https://github.com/esp8266/Arduino/releases/tag/2.4.0-rc2

Build of the library fails with

/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In constructor 'AsyncClient::AsyncClient(tcp_pcb*)':
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:77:28: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, pbuf*, int8_t) {aka signed char (*)(void*, tcp_pcb*, pbuf*, signed char)}' to 'tcp_recv_fn {aka long int (*)(void*, tcp_pcb*, pbuf*, long int)}' [-fpermissive]
     tcp_recv(_pcb, &_s_recv);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:318:18: error:   initializing argument 2 of 'void tcp_recv(tcp_pcb*, tcp_recv_fn)' [-fpermissive]
 void             tcp_recv    (struct tcp_pcb *pcb, tcp_recv_fn recv) ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:78:28: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, uint16_t) {aka signed char (*)(void*, tcp_pcb*, short unsigned int)}' to 'tcp_sent_fn {aka long int (*)(void*, tcp_pcb*, short unsigned int)}' [-fpermissive]
     tcp_sent(_pcb, &_s_sent);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:319:18: error:   initializing argument 2 of 'void tcp_sent(tcp_pcb*, tcp_sent_fn)' [-fpermissive]
 void             tcp_sent    (struct tcp_pcb *pcb, tcp_sent_fn sent)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:79:28: error: invalid conversion from 'void (*)(void*, int8_t) {aka void (*)(void*, signed char)}' to 'tcp_err_fn {aka void (*)(void*, long int)}' [-fpermissive]
     tcp_err(_pcb, &_s_error);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:321:18: error:   initializing argument 2 of 'void tcp_err(tcp_pcb*, tcp_err_fn)' [-fpermissive]
 void             tcp_err     (struct tcp_pcb *pcb, tcp_err_fn err)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:80:31: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*) {aka signed char (*)(void*, tcp_pcb*)}' to 'tcp_poll_fn {aka long int (*)(void*, tcp_pcb*)}' [-fpermissive]
     tcp_poll(_pcb, &_s_poll, 1);
                               ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:320:18: error:   initializing argument 2 of 'void tcp_poll(tcp_pcb*, tcp_poll_fn, u8_t)' [-fpermissive]
 void             tcp_poll    (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'bool AsyncClient::connect(IPAddress, uint16_t)':
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:128:25: error: invalid conversion from 'void (*)(void*, int8_t) {aka void (*)(void*, signed char)}' to 'tcp_err_fn {aka void (*)(void*, long int)}' [-fpermissive]
   tcp_err(pcb, &_s_error);
                         ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:321:18: error:   initializing argument 2 of 'void tcp_err(tcp_pcb*, tcp_err_fn)' [-fpermissive]
 void             tcp_err     (struct tcp_pcb *pcb, tcp_err_fn err)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'AsyncClient& AsyncClient::operator=(const AsyncClient&)':
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:166:28: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, pbuf*, int8_t) {aka signed char (*)(void*, tcp_pcb*, pbuf*, signed char)}' to 'tcp_recv_fn {aka long int (*)(void*, tcp_pcb*, pbuf*, long int)}' [-fpermissive]
     tcp_recv(_pcb, &_s_recv);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:318:18: error:   initializing argument 2 of 'void tcp_recv(tcp_pcb*, tcp_recv_fn)' [-fpermissive]
 void             tcp_recv    (struct tcp_pcb *pcb, tcp_recv_fn recv) ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:167:28: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, uint16_t) {aka signed char (*)(void*, tcp_pcb*, short unsigned int)}' to 'tcp_sent_fn {aka long int (*)(void*, tcp_pcb*, short unsigned int)}' [-fpermissive]
     tcp_sent(_pcb, &_s_sent);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:319:18: error:   initializing argument 2 of 'void tcp_sent(tcp_pcb*, tcp_sent_fn)' [-fpermissive]
 void             tcp_sent    (struct tcp_pcb *pcb, tcp_sent_fn sent)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:168:28: error: invalid conversion from 'void (*)(void*, int8_t) {aka void (*)(void*, signed char)}' to 'tcp_err_fn {aka void (*)(void*, long int)}' [-fpermissive]
     tcp_err(_pcb, &_s_error);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:321:18: error:   initializing argument 2 of 'void tcp_err(tcp_pcb*, tcp_err_fn)' [-fpermissive]
 void             tcp_err     (struct tcp_pcb *pcb, tcp_err_fn err)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:169:31: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*) {aka signed char (*)(void*, tcp_pcb*)}' to 'tcp_poll_fn {aka long int (*)(void*, tcp_pcb*)}' [-fpermissive]
     tcp_poll(_pcb, &_s_poll, 1);
                               ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:320:18: error:   initializing argument 2 of 'void tcp_poll(tcp_pcb*, tcp_poll_fn, u8_t)' [-fpermissive]
 void             tcp_poll    (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'int8_t AsyncClient::_connected(void*, int8_t)':
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:290:28: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, pbuf*, int8_t) {aka signed char (*)(void*, tcp_pcb*, pbuf*, signed char)}' to 'tcp_recv_fn {aka long int (*)(void*, tcp_pcb*, pbuf*, long int)}' [-fpermissive]
     tcp_recv(_pcb, &_s_recv);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:318:18: error:   initializing argument 2 of 'void tcp_recv(tcp_pcb*, tcp_recv_fn)' [-fpermissive]
 void             tcp_recv    (struct tcp_pcb *pcb, tcp_recv_fn recv) ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:291:28: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, uint16_t) {aka signed char (*)(void*, tcp_pcb*, short unsigned int)}' to 'tcp_sent_fn {aka long int (*)(void*, tcp_pcb*, short unsigned int)}' [-fpermissive]
     tcp_sent(_pcb, &_s_sent);
                            ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:319:18: error:   initializing argument 2 of 'void tcp_sent(tcp_pcb*, tcp_sent_fn)' [-fpermissive]
 void             tcp_sent    (struct tcp_pcb *pcb, tcp_sent_fn sent)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:292:31: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*) {aka signed char (*)(void*, tcp_pcb*)}' to 'tcp_poll_fn {aka long int (*)(void*, tcp_pcb*)}' [-fpermissive]
     tcp_poll(_pcb, &_s_poll, 1);
                               ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:320:18: error:   initializing argument 2 of 'void tcp_poll(tcp_pcb*, tcp_poll_fn, u8_t)' [-fpermissive]
 void             tcp_poll    (struct tcp_pcb *pcb, tcp_poll_fn poll, u8_t interval)ICACHE_FLASH_ATTR;
                  ^
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'void AsyncServer::begin()':
/Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:839:30: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, int8_t) {aka signed char (*)(void*, tcp_pcb*, signed char)}' to 'tcp_accept_fn {aka long int (*)(void*, tcp_pcb*, long int)}' [-fpermissive]
   tcp_accept(_pcb, &_s_accept);
                              ^
In file included from /Users/rs/projects/SmartWatch/libraries/ESPAsyncTCP/src/ESPAsyncTCP.cpp:27:0:
/Users/rs/Library/Arduino15/packages/esp8266/hardware/esp8266/2.4.0-rc2/tools/sdk/lwip/include/lwip/tcp.h:317:18: error:   initializing argument 2 of 'void tcp_accept(tcp_pcb*, tcp_accept_fn)' [-fpermissive]
 void             tcp_accept  (struct tcp_pcb *pcb, tcp_accept_fn accept) ICACHE_FLASH_ATTR;
                  ^

Not sure if this is issue of your library, but downgrade to rc1 works fine.

Print long flash string?

Hi, I'm using the class and it seems to work very nice. Only one question arises: How do I print/write a very long (8k) flash string? I have:

const char txt[]  PROGMEM = "..........."; // ~8k text, no \0s in it

AsyncClient *c;
AsyncPrinter *p; //Both are populated
// [...]
p->print("Hello World!"); // Works
p->write("Hello World!", strlen("Hello World!")); // Works
p->write(txt, strlen_P(txt)); // Does not compile
p->print(txt); // Compiles, but crashes the ESP

Thanks.

How to redirect to another port?

Hello

Working on a walled garden informational page using captive portal.

https://pastebin.com/jqLPZDLA

I am trying to figure out how listen on 443 for https requests and redirect to port 80 and served captive page.

Can someone please show me an example of how this would be done? Would I initialize another server on 443
AsyncWebServer server(443);
then use
server.request->redirect("http://apIP");?

Any insight greatly appreciated

How to use the async client?

My current code, which actually not works....

AsyncClient async_client;

.
.
.

String req ;
int8_t connected = async_client.connected();
Serial.print("connected: ");
Serial.println(connected) ;

  if (!connected  ) {
    Serial.println("connecting..") ;
    async_client.connect("192.168.0.17", 80);
  }
  else {
    String req = "POST /data HTTP/1.1 \nHost: " ;
    req += config_data.host_ip ;
    req += "/data" ;
    req += "\nCache-Control: no-cache \nContent-Type: application/json \nContent-Length: ";
    req += payload.length() ;
    req += "\nAccept: */*\n";
    req += payload.c_str() ;

    Serial.println(req);

    if ( async_client.canSend()) {
      async_client.add(req.c_str(), req.length() );
      bool sent = async_client.send();
      async_client.close();
      Serial.print("sent...") ;
      Serial.println(sent) ;
    }
  }

What is missing? How to make it work? HEEEELP PLEEASE!!

Is ESP32 supported?

Links2004 over at the arduinoWebSockets library thought that ESPAsyncTCP works on ESP32, but I've just had a pile of compile errors trying to include ESPAsyncTCP.

I've not been working with Arduino long and C is not my first language, so perhaps there's something obvious I need to do? The compile errors look like a conflict between different versions of a network library. For instance this is the first (and then loads more like that) :

C:\Arduino\libraries\ESPAsyncTCP-master\src\ESPAsyncTCP.cpp:113:36: error: macro "ip_route" requires 2 arguments, but only 1 given
netif* interface = ip_route(&addr);

Need example of sending TCP packets to a listener

Hello, I want to send data (probably in the form of TCP packets) to another device on a WAN which is listening with $netcat -l . I can't understand the SyncClient example well enough to figure this out.

Sorry for begging but will you please give an example of how to craft a TCP packet and send it to another IP:port address?

Http Post

Hi there. I saw that was an issue with Http Post and it was closed without any reply.

I am trying to send a post request with an async client.

I did some debugging with wireshark to find out what is the raw post format (including \r\n 's) but i can't get it work.

I am trying sth like this to a dump rest server i have for testing. There is no need for content type.
From a default rest client i just type anything to message body and post it nice n easy.

client->write("POST http://192.168.100.109:8089/myRest/getResponse HTTP/1.1\r\nHost: http://192.168.100.109:8089\r\n\r\nSomePostString");

Can i use post request with async client?

How can i send POST method???

I send 'GET' method.
but I want to send 'POST' method
How can I send 'POST' method??
besides, I want to send 'POST' method that json ?

sorry I can't english well...........

Thank you

Building with Arduino/esp8266 2.4.0-rc2

I've upgraded to 2.4.0-rc2 because it is supposed to have the KRAK WPA2 vulnerability fix.

Unfortunately, it seems like err_t may have gone from an int8_t to an int32_t -- You can see this in the diffs to the Arduino/esp8266 sdk here, where LWIP_ERR_T is defined to s32_t:

esp8266/Arduino@e049032#diff-171efba17be7978e6f6c00ab1b100ae0

err_t seems hard-coded in ESPAsyncTCP to an int32_t

I tried my hand at brute forcing the change, but so far just panics from my dev board, so I'm guessing I'm missing something somewhere. I'll continue to play and if I get something that works, I'll report back.

Update: Just a copy of the errors seems when compiling. Emphasis on where the function prototype differ.

ESPAsyncTCP.cpp: In constructor 'AsyncClient::AsyncClient(tcp_pcb*)':
ESPAsyncTCP.cpp:77:28: error: invalid conversion from
'int8_t ()(void, tcp_pcb*, pbuf*, int8_t) {aka signed char ()(void, tcp_pcb*, pbuf*, signed char)}'
to
'tcp_recv_fn {aka long int ()(void, tcp_pcb*, pbuf*, long int)}' [-fpermissive]
tcp_recv(_pcb, &_s_recv);

Other functions that also show similar errors in other places: tcp_recv, tcp_sent, tcp_err, tcp_poll, tcp_accept

Async client host use ip address, can't free memory

I am test async client host use domain name, can free memory, but host use ip address can't free memory.

void loop()
{
    if(millis() - previousTime > 200)
    {
        previousTime = millis();

        if(aClient1)//client already exists
        return;

        aClient1 = new AsyncClient();

        if(!aClient1)//could not allocate client
            return;

        aClient1->onConnect([](void * arg, AsyncClient * client) {

            client->write("tcp test string.");

            aClient1 = NULL;
            delete client;

        }, NULL);

        if(!aClient1->connect("192.168.0.100", 80))
        {
            AsyncClient * client = aClient1;
            aClient1 = NULL;
            delete client;
        }

        Serial.print("system_get_free_heap_size ");
        Serial.println(system_get_free_heap_size());
    }
}

SyncClient::connect hanging without end

Hi,

I think I found a bug in SyncClient. I tried to use SyncClient::connect(const char *host, uint16_t port) function, but when the host was unreachable (or it's port not opened), the function did not return at all. Kept hanging.

I think the problem might be with this while loop inside the function:
while(_client != NULL && !_client->connected() && !_client->disconnecting()) delay(1);

I figured out, that the _state variable of AsyncClient under the hood remains either 0 or 10, so it looks like it does not change from disconnected to connecting (or to anything else) state at all. Nevertheless I can see in Wireshark, that ESP is sending approx. 5-6 times the SYN message (the port on my computer is was not opened, no SYN-ACK response).

When the host and port is reachable the connect() works without any problem.

Best Regards

onData contains udp broadcast message

At first, thanks for this great library.

Now, to my problem:

in client::onData, I receive the expected String.
But sometimes, the client sends a udp broadcast:

4804    1984.991584 192.168.4.2 239.255.255.250 SSDP    216 M-SEARCH * HTTP/1.1 

The String "M-SEARCH * HTTP/1.1" will be concatenated to the data.
That should not be, should it?

btw:
Broadcast messages will be sent to Serial0, where I think, this comes from ESP-SDK.
I tried settings Serial.setDebugoutput(0), already. It does not work.

Do you know how to turn off?

Thanks in advance,

Matthias

2.3.0 ESPAsyncTCP.cpp:839:30: error: invalid conversion from 'long int (*)...

Hello ,
I can not compile due to the erros below:

ESPAsyncTCP\src\ESPAsyncTCP.cpp:839:30: error: invalid conversion from 'long int ()(void, tcp_pcb*, long int)' to 'tcp_accept_fn {aka signed char ()(void, tcp_pcb*, signed char)}' [-fpermissive]
tcp_accept(_pcb, &_s_accept);

any help would be appreciated.

thanks in advance

Ghislain

Won't compile under Core 2.4.0-rc2

ESPAsyncTCP won't compile under ESP8266 Core 2.4.0-rc2 with this error:

ESPAsyncTCP.cpp:77:28: error: invalid conversion from 'int8_t (*)(void*, tcp_pcb*, pbuf*, int8_t) {aka signed char (*)(void*, tcp_pcb*, pbuf*, signed char)}' to 'tcp_recv_fn {aka long int (*)(void*, tcp_pcb*, pbuf*, long int)}' [-fpermissive]
     tcp_recv(_pcb, &_s_recv);

It seems like conflict with lwip v2 implementation to me...

Use after free on aborted connections

from @igrr at gitter:

@andig @me-no-dev the case in the stack trace posted above looks pretty clear:

  • AsyncClient gets TCP close event and aborts the connection ESPAsyncTCP.cpp#L241
  • tcp_close returns some kind of error (for whatever reason, doesn't really matter) and the code goes down the path of calling abort()ESPAsyncTCP.cpp#L194
  • tcp_abort calls error callback with error code ERR_ABRT (via tcp_abandon) tcp.c#L398
  • we are in trouble already, because pcb has been destroyed, but we are trying to adjust the value of state, i.e. writing some structure which has been deallocated. ESPAsyncTCP.cpp#L222
  • error callback calls discard_cb ESPAsyncTCP.cpp#L225
  • this calls AsyncWebServerRequest::onDisconnect, which does delete client; WebRequest.cpp#L180
  • from there we go into AsyncClient destructor, which calls tcp_abort again ESPAsyncTCP.cpp#L81

From the first look, i think it might be sufficient to set _pcb to zero before calling tcp_abort.
but it might break something else (i haven't read all the async code yet)

AsyncWebServer - ESPAsyncTCP connecting after VPN

Hi,
Have you tried connecting the async web server via VPN? I cannot access to the Async Webserver when on vpn.
there is openVPN installed on my RPi-3, assigns 10.8.0.x IPs to VPN clients, routing is in place for 192.168.1.x in iptables. Works very well for any other device in the network, but hangs for Async Web server. I am not sure if there is something wrong with my routing rules, any idea?

*Same setup was working with standard ESP8266WebServer library before.

Thank you very much,
Best,

Example to start ESPAsyncTCP SSL Server

Hello. How do I upload files .cer and .key to esp8266?
I uploaded this files to esp FS, and use:

server.beginSecure("/server.cer","/server.key",NULL);

but it writes:

tcp_ssl_new_server_ctx: load private key '/server.key' failed

Can you help me how some example start SSL/TLS server?

Compiling Error (even on fresh Arduino Sketch)

Hey, thank you for developing and maintaining this library.

After I include the library in an empty Arduino sketch I get the following error:

AsyncPrinter.cpp:152:34: error: 'class cbuf' has no member named 'available' size_t available = _tx_buffer->available();

Am I doing something wrong? Am I missing something?

tx buffer chaining doesn't compile

C:\andi\arduino\hardware\esp8266com\esp8266\libraries\ESPAsyncTCP\src\ESPAsyncTCPbuffer.cpp: In constructor 'AsyncTCPbuffer::AsyncTCPbuffer(AsyncClient*)':

C:\andi\arduino\hardware\esp8266com\esp8266\libraries\ESPAsyncTCP\src\ESPAsyncTCPbuffer.cpp:46:9: error: '_TXbuffer' was not declared in this scope

     if (_TXbuffer == NULL || _RXbuffer == NULL) {

     ^

exit status 1
Error compiling.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.