diff --git a/samples/secure_tunneling/secure_tunnel/main.cpp b/samples/secure_tunneling/secure_tunnel/main.cpp index 4f39c3c10..d05663d6d 100644 --- a/samples/secure_tunneling/secure_tunnel/main.cpp +++ b/samples/secure_tunneling/secure_tunnel/main.cpp @@ -256,12 +256,15 @@ int main(int argc, char *argv[]) } }); + std::promise connectionPromise; + builder.WithOnConnectionSuccess([&](SecureTunnel *secureTunnel, const ConnectionSuccessEventData &eventData) { logConnectionData(eventData); /* Stream Start can only be called from Source Mode */ if (localProxyMode == AWS_SECURE_TUNNELING_SOURCE_MODE) { + connectionPromise.set_value(); /* Use a Multiplexing (Service Id) if available on this Secure Tunnel */ if (eventData.connectionData->getServiceId1().has_value()) { @@ -345,6 +348,8 @@ int main(int argc, char *argv[]) exit(-1); } + connectionPromise.get_future().wait_for(std::chrono::seconds(5)); + /* * In Destination mode the Secure Tunnel Client will remain open and echo messages that come in. * In Source mode the Secure Tunnel Client will send 4 messages and then disconnect and terminate.