toit icon indicating copy to clipboard operation
toit copied to clipboard

http server gets stuck when there are too many connections

Open floitsch opened this issue 3 years ago • 1 comments

Quoting from discord:

I got some TcpServer issues. It looks like there is a limit on the number of incoming connections. Thats is perfect. However, when the limit is reached something weird happens. The first part is ok, it parks the new connection. However, when another connection stops it seems like it doesnt allow the parked connections to connect fully. I tried this with a java client using the java.net.http.HttpClient. A way to provoke it real easy is to create a loop:

// Client code a la this
for (int i=0;i<100;i++) {
  var client = HttpClient.newBuilder().connectTimeout(Duration.ofSeconds(30)).build();
  var req = HttpRequest.newBuilder()
                .uri(new URI("http://" + esp32ip + "/postping"))
                .version(HttpClient.Version.HTTP_1_1)
                .timeout(Duration.ofSeconds(120))
                .POST(HttpRequest.BodyPublishers.ofString(bodyString))
                .build();
  client.send(request, HttpResponse.BodyHandlers.ofString());
}

Context

Uses http server with http packet. Logs say that close is called.

Recreating a fresh connection for each request works.

floitsch avatar Jul 14 '22 10:07 floitsch

Did we figure out what was going on here?

/cc @mikkeldamsgaard

kasperl avatar Aug 03 '22 05:08 kasperl