Skip to content

Errors after loading the Library #418

@davidlamason

Description

@davidlamason

Platform

ESP32

IDE / Tooling

Arduino (IDE/CLI)

What happened?

Down load and import into Arduino as a zip lib and use the sample sketch provided and it comes up with an error

In file included from C:\Users\David.OFFICE\Documents\Arduino\WaterMeter\Webserver\Webserver.ino:2:
c:\Users\David.OFFICE\Documents\Arduino\libraries\ESP_Async_WebServer\src/ESPAsyncWebServer.h: In member function 'tcp_state AsyncWebServer::state() const':
c:\Users\David.OFFICE\Documents\Arduino\libraries\ESP_Async_WebServer\src/ESPAsyncWebServer.h:1640:49: error: passing 'const AsyncServer' as 'this' argument discards qualifiers [-fpermissive]
1640 | return static_cast<tcp_state>(_server.status());
| ~~~~~~~~~~~~~~^~
In file included from c:\Users\David.OFFICE\Documents\Arduino\libraries\ESP_Async_WebServer\src/ESPAsyncWebServer.h:38:
c:\Users\David.OFFICE\Documents\Arduino\libraries\AsyncTCP\src/AsyncTCP.h:198:13: note: in call to 'uint8_t AsyncServer::status()'
198 | uint8_t status();
| ^~~~~~
exit status 1

Compilation error: exit status 1

Stack Trace

In file included from C:\Users\David.OFFICE\AppData\Local\Temp.arduinoIDE-unsaved202633-20680-xj71yi.qwg3\ServerState\ServerState.ino:20:
c:\Users\David.OFFICE\Documents\Arduino\libraries\ESP_Async_WebServer\src/ESPAsyncWebServer.h: In member function 'tcp_state AsyncWebServer::state() const':
c:\Users\David.OFFICE\Documents\Arduino\libraries\ESP_Async_WebServer\src/ESPAsyncWebServer.h:1640:49: error: passing 'const AsyncServer' as 'this' argument discards qualifiers [-fpermissive]
1640 | return static_cast<tcp_state>(_server.status());
| ~~~~~~~~~~~~~~^~
In file included from C:\Users\David.OFFICE\AppData\Local\Temp.arduinoIDE-unsaved202633-20680-xj71yi.qwg3\ServerState\ServerState.ino:10:
c:\Users\David.OFFICE\Documents\Arduino\libraries\AsyncTCP\src/AsyncTCP.h:198:13: note: in call to 'uint8_t AsyncServer::status()'
198 | uint8_t status();
| ^~~~~~
exit status 1

Compilation error: exit status 1

Minimal Reproductible Example (MRE)

// SPDX-License-Identifier: LGPL-3.0-or-later
// Copyright 2016-2026 Hristo Gochkov, Mathieu Carbou, Emil Muratov, Will Miles

//
// Server state example
//

#include <Arduino.h>
#if defined(ESP32) || defined(LIBRETINY)
#include <AsyncTCP.h>
#include <WiFi.h>
#elif defined(ESP8266)
#include <ESP8266WiFi.h>
#include <ESPAsyncTCP.h>
#elif defined(TARGET_RP2040) || defined(TARGET_RP2350) || defined(PICO_RP2040) || defined(PICO_RP2350)
#include <RPAsyncTCP.h>
#include <WiFi.h>
#endif

#include <ESPAsyncWebServer.h>

static AsyncWebServer server1(80);
static AsyncWebServer server2(80);

void setup() {
Serial.begin(115200);

#if ASYNCWEBSERVER_WIFI_SUPPORTED
WiFi.mode(WIFI_AP);
WiFi.softAP("esp-captive");
#endif

// server state returns one of the tcp_state enum values:
// enum tcp_state {
// CLOSED = 0,
// LISTEN = 1,
// SYN_SENT = 2,
// SYN_RCVD = 3,
// ESTABLISHED = 4,
// FIN_WAIT_1 = 5,
// FIN_WAIT_2 = 6,
// CLOSE_WAIT = 7,
// CLOSING = 8,
// LAST_ACK = 9,
// TIME_WAIT = 10
// };

assert(server1.state() == tcp_state::CLOSED);
assert(server2.state() == tcp_state::CLOSED);

server1.begin();

assert(server1.state() == tcp_state::LISTEN);
assert(server2.state() == tcp_state::CLOSED);

server2.begin();

assert(server1.state() == tcp_state::LISTEN);
assert(server2.state() == tcp_state::CLOSED);

Serial.println("Done!");
}

void loop() {
delay(100);
}

I confirm that:

  • I have read the documentation.
  • I have searched for similar discussions.
  • I have searched for similar issues.
  • I have looked at the examples.
  • I have upgraded to the lasted version of ESPAsyncWebServer (and AsyncTCP for ESP32).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions