From cce7107a1a867665ebe596e92400ec7f4b6b255c Mon Sep 17 00:00:00 2001 From: Bret Ambrose Date: Wed, 28 Aug 2019 12:16:45 -0700 Subject: [PATCH] H1b (#56) * Update for h1b API changes * Lambda capture scope crash * Options updates, formatting * Update CRT version dependency --- aws-common-runtime/CMakeLists.txt | 2 +- codebuild/common-posix.sh | 2 +- codebuild/common-windows.bat | 2 +- .../include/aws/discovery/DiscoveryClient.h | 62 ++++-- discovery/source/DiscoveryClient.cpp | 180 +++++++++++------- samples/greengrass/basic_discovery/main.cpp | 177 +++++++++-------- samples/jobs/describe_job_execution/main.cpp | 2 +- samples/shadow/shadow_sync/main.cpp | 2 +- 8 files changed, 262 insertions(+), 167 deletions(-) diff --git a/aws-common-runtime/CMakeLists.txt b/aws-common-runtime/CMakeLists.txt index 177fd4bdb..dd2ab3fa6 100644 --- a/aws-common-runtime/CMakeLists.txt +++ b/aws-common-runtime/CMakeLists.txt @@ -18,5 +18,5 @@ set(AWS_DEPS_DOWNLOAD_DIR "${AWS_DEPS_BUILD_DIR}/downloads" CACHE PATH "Dependen message("install dir ${AWS_DEPS_INSTALL_DIR}") set(AWS_CRT_CPP_URL "https://github.com/awslabs/aws-crt-cpp.git") -set(AWS_CRT_CPP_SHA "v0.4.6") +set(AWS_CRT_CPP_SHA "v0.5.3") include(BuildAwsCrtCpp) diff --git a/codebuild/common-posix.sh b/codebuild/common-posix.sh index f82e53b22..a63dda48b 100755 --- a/codebuild/common-posix.sh +++ b/codebuild/common-posix.sh @@ -17,7 +17,7 @@ fi # build aws-crt-cpp pushd $BUILD_PATH -git clone --branch v0.4.6 https://github.com/awslabs/aws-crt-cpp.git +git clone --branch v0.5.3 https://github.com/awslabs/aws-crt-cpp.git cd aws-crt-cpp cmake $CMAKE_ARGS -DBUILD_DEPS=ON ./ cmake --build . --target install diff --git a/codebuild/common-windows.bat b/codebuild/common-windows.bat index 2a9fb597f..877242ed4 100755 --- a/codebuild/common-windows.bat +++ b/codebuild/common-windows.bat @@ -8,7 +8,7 @@ mkdir %INSTALL_DIR% @rem build aws-crt-cpp mkdir %BUILDS_DIR%\aws-crt-cpp-build cd %BUILDS_DIR%\aws-crt-cpp-build -git clone --branch v0.4.6 https://github.com/awslabs/aws-crt-cpp.git +git clone --branch v0.5.3 https://github.com/awslabs/aws-crt-cpp.git cmake %CMAKE_ARGS% -DCMAKE_INSTALL_PREFIX="%INSTALL_DIR%" -DCMAKE_PREFIX_PATH="%INSTALL_DIR%" -DCMAKE_BUILD_TYPE="Release" -DBUILD_DEPS=ON aws-crt-cpp || goto error cmake --build . --target install || goto error diff --git a/discovery/include/aws/discovery/DiscoveryClient.h b/discovery/include/aws/discovery/DiscoveryClient.h index c0b259c21..a1cec59cd 100644 --- a/discovery/include/aws/discovery/DiscoveryClient.h +++ b/discovery/include/aws/discovery/DiscoveryClient.h @@ -22,26 +22,66 @@ namespace Aws { using OnDiscoverResponse = std::function; - struct DiscoveryClientConfig + class AWS_DISCOVERY_API DiscoveryClientConfig { + public: DiscoveryClientConfig() noexcept; - Crt::Allocator *allocator; - Crt::Io::ClientBootstrap *bootstrap; - Crt::Io::TlsContext *tlsContext; - Crt::Io::SocketOptions *socketOptions; - Crt::String region; - size_t maxConnections; - // TODO: when supported add proxy configuration. + DiscoveryClientConfig(const DiscoveryClientConfig &rhs) = default; + DiscoveryClientConfig(DiscoveryClientConfig &&rhs) = default; + + DiscoveryClientConfig &operator=(const DiscoveryClientConfig &rhs) = default; + DiscoveryClientConfig &operator=(DiscoveryClientConfig &&rhs) = default; + + ~DiscoveryClientConfig() = default; + + /** + * The client bootstrap to use for setting up and tearing down connections. + * Required. + */ + Crt::Io::ClientBootstrap *Bootstrap; + + /** + * The TLS options for all http connections made by this client. + * Optional. + */ + Crt::Optional TlsContext; + + /** + * The socket options of the connections made by the client. + * Required. + */ + Crt::Io::SocketOptions SocketOptions; + + /** + * The value of the Aws region to connect to. + * Required. + */ + Crt::String Region; + + /** + * The maximum number of concurrent connections allowed + */ + size_t MaxConnections; + + /** + * The proxy options for all http connections made by this client. + * Optional. + */ + Crt::Optional ProxyOptions; }; - class DiscoveryClient final + class AWS_DISCOVERY_API DiscoveryClient final { public: - DiscoveryClient(const DiscoveryClientConfig &) noexcept; - bool Discover(const Crt::String &thingName, const OnDiscoverResponse &onDiscoverResponse) noexcept; + static std::shared_ptr CreateClient( + const DiscoveryClientConfig &config, + Crt::Allocator *allocator = Crt::DefaultAllocator()); + private: + DiscoveryClient(const DiscoveryClientConfig &config, Crt::Allocator *allocator) noexcept; + std::shared_ptr m_connectionManager; Crt::String m_hostName; Crt::Allocator *m_allocator; diff --git a/discovery/source/DiscoveryClient.cpp b/discovery/source/DiscoveryClient.cpp index 86b71752f..180b2357c 100644 --- a/discovery/source/DiscoveryClient.cpp +++ b/discovery/source/DiscoveryClient.cpp @@ -13,7 +13,9 @@ */ #include +#include #include +#include #include #include @@ -22,23 +24,23 @@ namespace Aws namespace Discovery { DiscoveryClientConfig::DiscoveryClientConfig() noexcept - : allocator(Crt::DefaultAllocator()), bootstrap(nullptr), tlsContext(nullptr), socketOptions(nullptr), - region("us-east-1"), maxConnections(2) + : Bootstrap(nullptr), TlsContext(), SocketOptions(), Region(), MaxConnections(2), ProxyOptions() { } - DiscoveryClient::DiscoveryClient(const Aws::Discovery::DiscoveryClientConfig &clientConfig) noexcept + DiscoveryClient::DiscoveryClient( + const Aws::Discovery::DiscoveryClientConfig &clientConfig, + Crt::Allocator *allocator) noexcept { - AWS_ASSERT(clientConfig.tlsContext); - AWS_ASSERT(clientConfig.bootstrap); - AWS_ASSERT(clientConfig.socketOptions); + AWS_FATAL_ASSERT(clientConfig.TlsContext); + AWS_FATAL_ASSERT(clientConfig.Bootstrap); - m_allocator = clientConfig.allocator; + m_allocator = allocator; Crt::StringStream ss; - ss << "greengrass-ats.iot." << clientConfig.region << ".amazonaws.com"; + ss << "greengrass-ats.iot." << clientConfig.Region << ".amazonaws.com"; - Crt::Io::TlsConnectionOptions tlsConnectionOptions = clientConfig.tlsContext->NewConnectionOptions(); + Crt::Io::TlsConnectionOptions tlsConnectionOptions = clientConfig.TlsContext->NewConnectionOptions(); uint16_t port = 443; if (Crt::Io::TlsContextOptions::IsAlpnSupported()) @@ -54,17 +56,38 @@ namespace Aws Crt::ByteCursor serverName = Crt::ByteCursorFromCString(m_hostName.c_str()); tlsConnectionOptions.SetServerName(serverName); + Crt::Http::HttpClientConnectionOptions connectionOptions; + connectionOptions.SocketOptions = clientConfig.SocketOptions; + connectionOptions.Bootstrap = clientConfig.Bootstrap; + connectionOptions.TlsOptions = tlsConnectionOptions; + connectionOptions.HostName = Crt::String((const char *)serverName.ptr, serverName.len); + connectionOptions.Port = port; + if (clientConfig.ProxyOptions) + { + connectionOptions.ProxyOptions = *clientConfig.ProxyOptions; + } + Crt::Http::HttpClientConnectionManagerOptions connectionManagerOptions; - connectionManagerOptions.socketOptions = clientConfig.socketOptions; - connectionManagerOptions.bootstrap = clientConfig.bootstrap; - connectionManagerOptions.tlsConnectionOptions = &tlsConnectionOptions; - connectionManagerOptions.maxConnections = clientConfig.maxConnections; - connectionManagerOptions.initialWindowSize = SIZE_MAX; - connectionManagerOptions.hostName = serverName; - connectionManagerOptions.port = port; - - m_connectionManager = Crt::Http::HttpClientConnectionManager::NewClientConnectionManager( - connectionManagerOptions, clientConfig.allocator); + connectionManagerOptions.ConnectionOptions = connectionOptions; + connectionManagerOptions.MaxConnections = clientConfig.MaxConnections; + + m_connectionManager = + Crt::Http::HttpClientConnectionManager::NewClientConnectionManager(connectionManagerOptions, allocator); + } + + std::shared_ptr DiscoveryClient::CreateClient( + const Aws::Discovery::DiscoveryClientConfig &clientConfig, + Crt::Allocator *allocator) + { + auto *toSeat = static_cast(aws_mem_acquire(allocator, sizeof(DiscoveryClient))); + if (toSeat) + { + toSeat = new (toSeat) DiscoveryClient(clientConfig, allocator); + return std::shared_ptr( + toSeat, [allocator](DiscoveryClient *client) { Crt::Delete(client, allocator); }); + } + + return nullptr; } struct ClientCallbackContext @@ -77,8 +100,7 @@ namespace Aws const Crt::String &thingName, const OnDiscoverResponse &onDiscoverResponse) noexcept { - - auto *callbackContext = Crt::New(m_allocator); + auto callbackContext = Crt::MakeShared(m_allocator); if (!callbackContext) { return false; @@ -89,69 +111,81 @@ namespace Aws bool res = m_connectionManager->AcquireConnection( [this, callbackContext, thingName, onDiscoverResponse]( std::shared_ptr connection, int errorCode) { - if (!errorCode) + if (errorCode) { - Crt::StringStream ss; - ss << "/greengrass/discover/thing/" << thingName; - Crt::String uriStr = ss.str(); - Crt::Http::HttpRequestOptions requestOptions; - requestOptions.uri = Crt::ByteCursorFromCString(uriStr.c_str()); - requestOptions.method = Crt::ByteCursorFromCString("GET"); - - Crt::Http::HttpHeader hostNameHeader; - hostNameHeader.name = Crt::ByteCursorFromCString("host"); - hostNameHeader.value = Crt::ByteCursorFromCString(m_hostName.c_str()); - - requestOptions.headerArray = &hostNameHeader; - requestOptions.headerArrayLength = 1; - - requestOptions.onStreamOutgoingBody = nullptr; - requestOptions.onIncomingHeaders = - [](Crt::Http::HttpStream &, const Crt::Http::HttpHeader *, std::size_t) {}; - requestOptions.onIncomingHeadersBlockDone = - [callbackContext](Crt::Http::HttpStream &stream, bool) { - callbackContext->responseCode = stream.GetResponseStatusCode(); - }; - requestOptions.onIncomingBody = - [callbackContext](Crt::Http::HttpStream &, const Crt::ByteCursor &data, std::size_t &) { - callbackContext->ss.write(reinterpret_cast(data.ptr), data.len); - }; - requestOptions.onStreamComplete = [this, connection, callbackContext, onDiscoverResponse]( - Crt::Http::HttpStream &stream, int errorCode) { - if (!errorCode && callbackContext->responseCode == 200) - { - Crt::JsonObject jsonObject(callbackContext->ss.str()); - DiscoverResponse response(jsonObject.View()); - onDiscoverResponse(&response, AWS_ERROR_SUCCESS, callbackContext->responseCode); - } - else - { - if (!errorCode) - { - errorCode = AWS_ERROR_UNKNOWN; - } - onDiscoverResponse(nullptr, errorCode, callbackContext->responseCode); - } + onDiscoverResponse(nullptr, errorCode, 0); + return; + } - Crt::Delete(callbackContext, m_allocator); - }; + auto request = Aws::Crt::MakeShared(m_allocator, m_allocator); + if (request == nullptr) + { + onDiscoverResponse(nullptr, Crt::LastErrorOrUnknown(), 0); + return; + } - if (!connection->NewClientStream(requestOptions)) - { - onDiscoverResponse(nullptr, aws_last_error(), 0); - Crt::Delete(callbackContext, m_allocator); - } + Crt::StringStream ss; + ss << "/greengrass/discover/thing/" << thingName; + Crt::String uriStr = ss.str(); + if (!request->SetMethod(Crt::ByteCursorFromCString("GET"))) + { + onDiscoverResponse(nullptr, Crt::LastErrorOrUnknown(), 0); + return; + } + if (!request->SetPath(Crt::ByteCursorFromCString(uriStr.c_str()))) + { + onDiscoverResponse(nullptr, Crt::LastErrorOrUnknown(), 0); + return; + } + + Crt::Http::HttpHeader hostNameHeader; + hostNameHeader.name = Crt::ByteCursorFromCString("host"); + hostNameHeader.value = Crt::ByteCursorFromCString(m_hostName.c_str()); + + if (!request->AddHeader(hostNameHeader)) + { + onDiscoverResponse(nullptr, Crt::LastErrorOrUnknown(), 0); return; } - onDiscoverResponse(nullptr, errorCode, 0); - Crt::Delete(callbackContext, m_allocator); + Crt::Http::HttpRequestOptions requestOptions; + requestOptions.request = request.get(); + requestOptions.onIncomingHeaders = + [](Crt::Http::HttpStream &, const Crt::Http::HttpHeader *, std::size_t) {}; + requestOptions.onIncomingHeadersBlockDone = [callbackContext](Crt::Http::HttpStream &stream, bool) { + callbackContext->responseCode = stream.GetResponseStatusCode(); + }; + requestOptions.onIncomingBody = + [callbackContext](Crt::Http::HttpStream &, const Crt::ByteCursor &data) { + callbackContext->ss.write(reinterpret_cast(data.ptr), data.len); + }; + requestOptions.onStreamComplete = [request, connection, callbackContext, onDiscoverResponse]( + Crt::Http::HttpStream &, int errorCode) { + if (!errorCode && callbackContext->responseCode == 200) + { + Crt::JsonObject jsonObject(callbackContext->ss.str()); + DiscoverResponse response(jsonObject.View()); + onDiscoverResponse(&response, AWS_ERROR_SUCCESS, callbackContext->responseCode); + } + else + { + if (!errorCode) + { + errorCode = AWS_ERROR_UNKNOWN; + } + onDiscoverResponse(nullptr, errorCode, callbackContext->responseCode); + } + }; + + if (!connection->NewClientStream(requestOptions)) + { + onDiscoverResponse(nullptr, Crt::LastErrorOrUnknown(), 0); + } }); if (!res) { - Crt::Delete(callbackContext, m_allocator); return false; } diff --git a/samples/greengrass/basic_discovery/main.cpp b/samples/greengrass/basic_discovery/main.cpp index abd4bf8d3..53fbdd79f 100644 --- a/samples/greengrass/basic_discovery/main.cpp +++ b/samples/greengrass/basic_discovery/main.cpp @@ -35,7 +35,8 @@ static void s_printHelp() "basic-discovery --region --cert " " --key --ca_file " " --thing_name --topic " - " --mode --message \n\n"); + " --mode --message " + " --proxy-host --proxy-port \n\n"); fprintf(stdout, "region: the region for your green grass groups, default us-east-1\n"); fprintf(stdout, "cert: path to your client certificate in PEM format\n"); fprintf(stdout, "key: path to your key in PEM format\n"); @@ -45,6 +46,8 @@ static void s_printHelp() fprintf(stdout, "topic: targeted topic. Default is sdk/test/cpp-v2\n"); fprintf(stdout, "mode: default both\n"); fprintf(stdout, "message: message to publish. default 'Hello World'\n"); + fprintf(stdout, "proxy-host: proxy host to use for discovery call. Default is to not use a proxy.\n"); + fprintf(stdout, "proxy-port: proxy port to use for discovery call.\n"); } bool s_cmdOptionExists(char **begin, char **end, const String &option) @@ -70,6 +73,8 @@ int main(int argc, char *argv[]) */ ApiHandle apiHandle; + String proxyHost; + uint16_t proxyPort = 0; String region("us-east-1"); String certificatePath; String keyPath; @@ -112,6 +117,17 @@ int main(int argc, char *argv[]) message = s_getCmdOption(argv, argv + argc, "--message"); } + if (s_cmdOptionExists(argv, argv + argc, "--proxy-host")) + { + proxyHost = s_getCmdOption(argv, argv + argc, "--proxy-host"); + } + + if (s_cmdOptionExists(argv, argv + argc, "--proxy-port")) + { + String portString = s_getCmdOption(argv, argv + argc, "--proxy-port"); + proxyPort = static_cast(atoi(portString.c_str())); + } + Io::EventLoopGroup eventLoopGroup(1); if (!eventLoopGroup) { @@ -131,7 +147,7 @@ int main(int argc, char *argv[]) if (!tlsCtx) { - fprintf(stderr, "Tls Context creation failed with error %s\n", ErrorDebugString(tlsCtx.LastError())); + fprintf(stderr, "Tls Context creation failed with error %s\n", ErrorDebugString(LastErrorOrUnknown())); exit(-1); } @@ -140,12 +156,7 @@ int main(int argc, char *argv[]) * tells us. */ Io::SocketOptions socketOptions; - socketOptions.connect_timeout_ms = 3000; - socketOptions.domain = AWS_SOCKET_IPV4; - socketOptions.type = AWS_SOCKET_STREAM; - socketOptions.keep_alive_interval_sec = 0; - socketOptions.keep_alive_timeout_sec = 0; - socketOptions.keepalive = false; + socketOptions.SetConnectTimeoutMs(3000); Io::DefaultHostResolver hostResolver(eventLoopGroup, 64, 30); Io::ClientBootstrap bootstrap(eventLoopGroup, hostResolver); @@ -157,12 +168,20 @@ int main(int argc, char *argv[]) } DiscoveryClientConfig clientConfig; - clientConfig.bootstrap = &bootstrap; - clientConfig.socketOptions = &socketOptions; - clientConfig.tlsContext = &tlsCtx; - clientConfig.region = region; + clientConfig.Bootstrap = &bootstrap; + clientConfig.SocketOptions = socketOptions; + clientConfig.TlsContext = tlsCtx; + clientConfig.Region = region; - DiscoveryClient discoveryClient(clientConfig); + Aws::Crt::Http::HttpClientConnectionProxyOptions proxyOptions; + if (proxyHost.length() > 0 && proxyPort != 0) + { + proxyOptions.HostName = proxyHost; + proxyOptions.Port = proxyPort; + clientConfig.ProxyOptions = proxyOptions; // + } + + auto discoveryClient = DiscoveryClient::CreateClient(clientConfig); Aws::Iot::MqttClient mqttClient(bootstrap); std::shared_ptr connection(nullptr); @@ -172,7 +191,7 @@ int main(int argc, char *argv[]) std::atomic connectionFinished(false); std::atomic shutdownCompleted(false); - discoveryClient.Discover(thingName, [&](DiscoverResponse *response, int error, int httpResponseCode) { + discoveryClient->Discover(thingName, [&](DiscoverResponse *response, int error, int httpResponseCode) { if (!error && response->GGGroups) { auto groupToUse = std::move(response->GGGroups->at(0)); @@ -200,81 +219,83 @@ int main(int argc, char *argv[]) exit(-1); } - connection->OnConnectionCompleted = - [&, connectivityInfo]( - Mqtt::MqttConnection &conn, int errorCode, Mqtt::ReturnCode returnCode, bool sessionPresent) { - if (!errorCode) + connection->OnConnectionCompleted = [&, connectivityInfo, groupToUse]( + Mqtt::MqttConnection &conn, + int errorCode, + Mqtt::ReturnCode /*returnCode*/, + bool /*sessionPresent*/) { + if (!errorCode) + { + fprintf( + stdout, + "Connected to group %s, using connection to %s:%d\n", + groupToUse.GGGroupId->c_str(), + connectivityInfo.HostAddress->c_str(), + (int)connectivityInfo.Port.value()); + + if (mode == "both" || mode == "subscribe") { - fprintf( - stdout, - "Connected to group %s, using connection to %s:%d\n", - groupToUse.GGGroupId->c_str(), - connectivityInfo.HostAddress->c_str(), - (int)connectivityInfo.Port.value()); - - if (mode == "both" || mode == "subscribe") - { - auto onPublish = [&](Mqtt::MqttConnection &connection, - const String &receivedOnTopic, - const ByteBuf &payload) { - fprintf(stdout, "Publish received on topic %s\n", receivedOnTopic.c_str()); - fprintf(stdout, "Message: \n"); - fwrite(payload.buffer, 1, payload.len, stdout); - fprintf(stdout, "\n"); - }; - - auto onSubAck = [&](Mqtt::MqttConnection &connection, - uint16_t packetId, - const String &topic, - Mqtt::QOS qos, - int errorCode) { - if (!errorCode) - { - fprintf(stdout, "Successfully subscribed to %s\n", topic.c_str()); - connectionFinished = true; - semaphore.notify_one(); - } - else - { - fprintf( - stderr, - "Failed to subscribe to %s with error %s. Exiting\n", - topic.c_str(), - aws_error_debug_str(errorCode)); - exit(-1); - } - }; - - conn.Subscribe(topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, onPublish, onSubAck); - } - else - { - connectionFinished = true; - semaphore.notify_one(); - } + auto onPublish = [&](Mqtt::MqttConnection & /*connection*/, + const String &receivedOnTopic, + const ByteBuf &payload) { + fprintf(stdout, "Publish received on topic %s\n", receivedOnTopic.c_str()); + fprintf(stdout, "Message: \n"); + fwrite(payload.buffer, 1, payload.len, stdout); + fprintf(stdout, "\n"); + }; + + auto onSubAck = [&](Mqtt::MqttConnection & /*connection*/, + uint16_t /*packetId*/, + const String &topic, + Mqtt::QOS /*qos*/, + int errorCode) { + if (!errorCode) + { + fprintf(stdout, "Successfully subscribed to %s\n", topic.c_str()); + connectionFinished = true; + semaphore.notify_one(); + } + else + { + fprintf( + stderr, + "Failed to subscribe to %s with error %s. Exiting\n", + topic.c_str(), + aws_error_debug_str(errorCode)); + exit(-1); + } + }; + + conn.Subscribe(topic.c_str(), AWS_MQTT_QOS_AT_MOST_ONCE, onPublish, onSubAck); } else { - fprintf( - stderr, - "Error connecting to group %s, using connection to %s:%d\n", - groupToUse.GGGroupId->c_str(), - connectivityInfo.HostAddress->c_str(), - (int)connectivityInfo.Port.value()); - fprintf(stderr, "Error: %s\n", aws_error_debug_str(errorCode)); - exit(-1); + connectionFinished = true; + semaphore.notify_one(); } - }; + } + else + { + fprintf( + stderr, + "Error connecting to group %s, using connection to %s:%d\n", + groupToUse.GGGroupId->c_str(), + connectivityInfo.HostAddress->c_str(), + (int)connectivityInfo.Port.value()); + fprintf(stderr, "Error: %s\n", aws_error_debug_str(errorCode)); + exit(-1); + } + }; connection->OnConnectionInterrupted = [](Mqtt::MqttConnection &, int errorCode) { fprintf(stderr, "Connection interrupted with error %s\n", aws_error_debug_str(errorCode)); }; - connection->OnConnectionResumed = [](Mqtt::MqttConnection &, - Mqtt::ReturnCode connectCode, - bool sessionPresent) { fprintf(stdout, "Connection resumed\n"); }; + connection->OnConnectionResumed = [](Mqtt::MqttConnection & /*connection*/, + Mqtt::ReturnCode /*connectCode*/, + bool /*sessionPresent*/) { fprintf(stdout, "Connection resumed\n"); }; - connection->OnDisconnect = [&](Mqtt::MqttConnection &connection) { + connection->OnDisconnect = [&](Mqtt::MqttConnection & /*connection*/) { fprintf(stdout, "Connection disconnected. Shutting Down.....\n"); shutdownCompleted = true; semaphore.notify_one(); diff --git a/samples/jobs/describe_job_execution/main.cpp b/samples/jobs/describe_job_execution/main.cpp index 7aeadcafc..59d2b2f8b 100644 --- a/samples/jobs/describe_job_execution/main.cpp +++ b/samples/jobs/describe_job_execution/main.cpp @@ -198,7 +198,7 @@ int main(int argc, char *argv[]) /* * Invoked when a disconnect message has completed. */ - auto onDisconnect = [&](Mqtt::MqttConnection &conn) { + auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { { fprintf(stdout, "Disconnect completed\n"); connectionClosed = true; diff --git a/samples/shadow/shadow_sync/main.cpp b/samples/shadow/shadow_sync/main.cpp index 249703121..b3375faa0 100644 --- a/samples/shadow/shadow_sync/main.cpp +++ b/samples/shadow/shadow_sync/main.cpp @@ -237,7 +237,7 @@ int main(int argc, char *argv[]) /* * Invoked when a disconnect message has completed. */ - auto onDisconnect = [&](Mqtt::MqttConnection &conn) { + auto onDisconnect = [&](Mqtt::MqttConnection & /*conn*/) { { fprintf(stdout, "Disconnect completed\n"); connectionClosed = true;