aws-samples / aws-iot-securetunneling-localproxy

AWS Iot Secure Tunneling local proxy reference C++ implementation
https://docs.aws.amazon.com/iot/latest/developerguide/what-is-secure-tunneling.html
Apache License 2.0
73 stars 70 forks source link

Secure tunnel cannot support multiple requests at the same time #71

Closed yilin01 closed 2 years ago

yilin01 commented 2 years ago

Describe the bug

After a destination device and a source device are connected to an established secure tunnel, the source device cannot send multiple http requests simultaneously to the destination device.

To Reproduce

Steps to reproduce the behavior:

  1. Create a simple web server for a port (eg. 8080) at the destination device and make sure the web server takes a little bit time (e.g. 5 sec) to send back the response. Verify the curl localhost: 8080 returns response after a period of time (5 sec)
  2. establish tunnel with destination port1=8080 and source port1 = 18080. Connect the destination device and source device to the tunnel with corresponding ports.
  3. in the source device, curl the destination web server by using command curl localhost:18080. You should see it will have a response after 5 sec.
  4. Trying to execute the curl localhost:18080 in multiple terminal windows at the same time in source device. You can notice that only one terminal window has correct response. All other terminal windows will get "curl: (56) Recv failure: Connection reset by peer" error. If we execute the command sequentially (execute one after the previous one returns the response), then we don't see any issue. Expected behavior

Source device should be able to send multiple http requests simultaneously and receive the correct responses to the destination device.

Actual behavior

When source device sends multiple http requests simultaneously to the destination device, only one request gets the correct response. All other requests fail.

Logs

If applicable, add full logs of errors and outputs to help explain your problem. Preferabbly, you can also increase the verbosity, for example to enable debug logs for the localproxy, you can use the cli option -v 6

Environment (please complete the following information):

Additional context

Add any other context about the problem here.

kareali commented 2 years ago

Hi @yilin01 multiple requests to the same port are not supported at the moment, currently you can create single TCP connection per port at a time (up to 3 ports). This is currently tracked in #22