Skip to content

[BUG] server not reachable after calling end() and begin(). #21

Closed

Description

@mkalkbrenner
  • Which board: ESP32S3
AsyncWebServer *server = new AsyncWebServer(80);
// Start the web server
server->begin();

delay(10000);
server->end();

delay(10000);
server->begin();

The server works fine. But if I stop the sever and start it again later, it isn't reachable anymore.

Activity

  1. mkalkbrenner commented on Jan 27, 2025

    @mkalkbrenner
    Author

    Some more tests.
    Even that doesn't work:

    AsyncWebServer *server = new AsyncWebServer(80);
    // Start the web server
    server->begin();
    
    delay(10000);
    server->end();
    delete server;
    server = nullptr;
    
    delay(10000);
    server = new AsyncWebServer(80);
    server->begin();

    The server is not reachable on port 80 after the "restart".

    But if I do this, I can reach the server on port 81:

    AsyncWebServer *server = new AsyncWebServer(80);
    // Start the web server
    server->begin();
    
    delay(10000);
    server->end();
    delete server;
    server = nullptr;
    
    delay(10000);
    server = new AsyncWebServer(81);
    server->begin();
  2. added
    Type: Bug
    and removed on Jan 27, 2025
  3. mathieucarbou commented on Jan 27, 2025

    @mathieucarbou
    Member

    I can reproduce indeed. Ahah! I didn't have my WiFi Client activated :P

    So I cannot reproduce.

    you can add at the end of the SimpleServer:

      Serial.println("begin()");
      server.begin();
    
      delay(10000);
      Serial.println("end()");
      server.end();
      delay(10000);
      Serial.println("begin()");
      server.begin();
    
    • wait for begin()
    • do a curl requests curl -v http://192.168.4.1
    • wait for end(), then begin()
    • do a curl request curl -v http://192.168.4.1
    begin()
    * Connection from 192.168.4.2:58749
    > GET / HTTP/1.1
    > Host: 192.168.4.1
    > User-Agent: curl/8.11.1
    > Accept: */*
    >
    * Processed in 1 ms
    < HTTP/1.1 200 OK
    < connection: close
    <
    end()
    begin()
    =========== After Setup Start ============
    INTERNAL Memory Info:
    ------------------------------------------
      Total Size        :   326716 B ( 319.1 KB)
      Free Bytes        :   219248 B ( 214.1 KB)
      Allocated Bytes   :    95436 B (  93.2 KB)
      Minimum Free Bytes:   197212 B ( 192.6 KB)
      Largest Free Block:   110580 B ( 108.0 KB)
    ------------------------------------------
    GPIO Info:
    ------------------------------------------
      GPIO : BUS_TYPE[bus/unit][chan]
      --------------------------------------  
         1 : UART_TX[0]
         3 : UART_RX[0]
         4 : GPIO
    ============ After Setup End =============
    Free heap: 219248
    Free heap: 219248
    * Connection from 192.168.4.2:58794
    > GET / HTTP/1.1
    > Host: 192.168.4.1
    > User-Agent: curl/8.11.1
    > Accept: */*
    >
    * Processed in 2 ms
    < HTTP/1.1 200 OK
    < connection: close
    <
    Free heap: 219248
    Free heap: 219248
    

    I will move to a discussion until it can be proven there is an issue, or until you found what is wrong on your setup.

    Maybe post a complete ino file to reproduce.

    Also, please test with the SimpleServer example ;-)

  4. locked and limited conversation to collaborators on Jan 27, 2025
  5. converted this issue into a discussion #23 on Jan 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type: Bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions