aws / aws-iot-device-sdk-cpp-v2

Next generation AWS IoT Client SDK for C++ using the AWS Common Runtime
Apache License 2.0
185 stars 108 forks source link

AWS tunnel: messages sent very quickly not handled #649

Closed grinaudo closed 1 year ago

grinaudo commented 1 year ago

Describe the bug

By sending more than one messages using the member function Aws::Iotsecuretunneling::SecureTunnel::SendMessage in a very short time the messages are not actually sent. Neither the OnSendMessageComplete registered with Aws::Iotsecuretunneling::SecureTunnelBuilder::WithOnMessageReceived is raised for all messages nor all the messages are received from the other side of the tunnel.

Out of 10 messages sent consecutively only 2 to 5 are actually sent.

Expected Behavior

I think the event registered in Aws::Iotsecuretunneling::SecureTunnelBuilder::WithOnMessageReceived should be invoked for each sent message and the other side of the tunnel should receive all messages sent regardless of the sending timing.

Current Behavior

By sending 10 messages consecutively only for the first 2 or 3 (sometimes up to 5) the OnSendMessageComplete event is raised. Possibly after 15 seconds (and every 15-20 seconds) another OnSendMessageComplete is raised.

The problem becomes much less frequent by adding a 1 ms sleep between SendMessage calls.

Reproduction Steps

main.zip

Possible Solution

No response

Additional Information/Context

In the attached file you can find two tunnels creation (through the function create_secure_tunnel) and a loop of 10 SendMessage in the main function. I also tried with different message size but it seems to have no effect on the problem. I am using a machine with 16 cores so the event loop groups size should be set to 8. I also tried on a device with 1 core (event loop group size set to 1) but it also have no effect.

SDK version used

I tried with 1.30.0 and 1.30.1

Environment details (OS name and version, etc.)

Win10 (Visual Studio 2022 19.37.32822 for x64), Ubuntu 20.04 (g++ 9.4)

jmklix commented 1 year ago

Can you upload your repro-example not in a zip file?

grinaudo commented 1 year ago

I am not sure I understand. Is it ok a gz file? The content is just the source code file. I compiled it using an integrated system (I made a conan package of the aws sdk on our internal server and I am using cmake) but I think you can just substitute the main.cpp in your secure tunnel samples ( https://github.com/aws/aws-iot-device-sdk-cpp-v2/blob/main/samples/secure_tunneling/secure_tunnel/main.cpp ) and it should compile.

main.cpp.gz

jmklix commented 1 year ago

Any type of zip file is not preferred, as they can contain malware or other malicious files. Could you possibly post just the plain cpp files on this issue?

grinaudo commented 1 year ago

The github web application does not allow me to upload a file with a cpp extension. I just added the extension .txt to the file name. Please just rename it and let me know. main.cpp.txt

sfod commented 1 year ago

Thanks for example, I managed to reproduce the issue. The example looks OK at first glance, so probably something is happening in the internals of secure tunnel. This will require some time to dig.

sfod commented 1 year ago

The issue is fixed in the latest release: https://github.com/aws/aws-iot-device-sdk-cpp-v2/releases/tag/v1.30.2

grinaudo commented 1 year ago

Thank you!

github-actions[bot] commented 1 year ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.