esp32_https_server icon indicating copy to clipboard operation
esp32_https_server copied to clipboard

Parallel communication

Open r-zlotorzynski opened this issue 6 years ago • 1 comments

I'm using a sample file in the Examples/Async-Server directory.

I need to send very large response files.

Currently, communication looks like this:

  1. receiving the request from the client 1
  2. sending a response to the client 1
  3. receiving the request from the client 2
  4. sending a response to the client 2 ... etc.

So customer 2 has to wait until client 1 gets the whole answer. I want to avoid it.

And I would like to handle all requests in parallel:

  1. receiving the request from the client 1
  2. sending a first packet response to the client 1
  3. receiving the request from the client 2
  4. sending a first packet response to the client 2
  5. sending a next packet response to the client 1
  6. sending a next packet response to the client 2 ... etc. every loop

Is it possible? How can I do this?

r-zlotorzynski avatar Aug 01 '19 15:08 r-zlotorzynski

At the moment that's not possible, as the handler function would need to tell the server that the request is only processed partially. I assume that it's possible, but it would need some major changes to how HTTPConnection handles the requests.

The only thing that the ASync-Server example can provide is that your regular loop() code would run during long requests, if the handler function blocks (e.g. due to waiting for I/O).

fhessel avatar Aug 03 '19 16:08 fhessel