GithubHelp home page GithubHelp logo

aws / aws-iot-device-sdk-cpp-v2 Goto Github PK

View Code? Open in Web Editor NEW
178.0 26.0 106.0 7.4 MB

Next generation AWS IoT Client SDK for C++ using the AWS Common Runtime

License: Apache License 2.0

CMake 2.89% C++ 89.80% C 0.45% Shell 0.49% Python 6.14% Gherkin 0.23%
hacktoberfest

aws-iot-device-sdk-cpp-v2's Introduction

AWS IoT Device SDK for C++ v2

This document provides information about the AWS IoT device SDK for C++ V2. This SDK is built on the AWS Common Runtime

Jump To:

Supported Architectures

Linux

  • manylinux2014-x64
  • manylinux2014-x86
  • al2-x64
  • alpine-3.16-x64
  • alpine-3.16-x86
  • alpine-3.16-armv6
  • alpine-3.16-armv7
  • alpine-3.16-arm64
  • raspberry pi bullseye
  • ARM64 /aarch64
  • ArmV7
  • x86_64
  • x86

Windows

  • Win32
  • x64
  • ARM64

Mac

  • Apple Silicone (M1 and higher)
  • Apple Intel Chips (x86_64)

Installation

Minimum Requirements

  • C++ 11 or higher
    • Clang 3.9+ or GCC 4.8+ or MSVC 2015+
  • CMake 3.1+

Step-by-step instructions

Build from source

# Create a workspace directory to hold all the SDK files
mkdir sdk-workspace
cd sdk-workspace
# Clone the repository
git clone --recursive https://github.com/aws/aws-iot-device-sdk-cpp-v2.git
# Make a build directory for the SDK. Can use any name.
mkdir aws-iot-device-sdk-cpp-v2-build
cd aws-iot-device-sdk-cpp-v2-build
# continue with the build steps below based on OS

MacOS and Linux

# Generate the SDK build files.
# -DCMAKE_INSTALL_PREFIX needs to be the absolute/full path to the directory.
#     (Example: "/Users/example/sdk-workspace/).
# -DCMAKE_BUILD_TYPE can be "Release", "RelWithDebInfo", or "Debug"
cmake -DCMAKE_INSTALL_PREFIX="<absolute path to sdk-workspace>" -DCMAKE_BUILD_TYPE="Debug" ../aws-iot-device-sdk-cpp-v2
# Build and install the library. Once installed, you can develop with the SDK and run the samples
cmake --build . --target install

Windows

# Generate the SDK build files.
# -DCMAKE_INSTALL_PREFIX needs to be the absolute/full path to the directory.
#     (Example: "C:/users/example/sdk-workspace/).
cmake -DCMAKE_INSTALL_PREFIX="<absolute path sdk-workspace dir>" ../aws-iot-device-sdk-cpp-v2
# Build and install the library. Once installed, you can develop with the SDK and run the samples
# -config can be "Release", "RelWithDebInfo", or "Debug"
cmake --build . --target install --config "Debug"

Windows specific notes:

  • Due to maximum path length limitations in the Windows API, we recommend cloning to a short path like: C:\dev\iotsdk
  • --config is only REQUIRED for multi-configuration build tools (VisualStudio/MsBuild being the most common).

Linux specific notes:

If your application uses OpenSSL, configure with -DUSE_OPENSSL=ON.

The IoT SDK does not use OpenSSL for TLS. On Apple and Windows, the OS's default TLS library is used. On Linux, s2n-tls is used. But s2n-tls uses libcrypto, the cryptography math library bundled with OpenSSL. To simplify the build process, the source code for s2n-tls and libcrypto are included as git submodules and built along with the IoT SDK. But if your application is also loading the system installation of OpenSSL (i.e. your application uses libcurl which uses libssl which uses libcrypto) there may be crashes as the application tries to use two different versions of libcrypto at once.

Setting -DUSE_OPENSSL=ON will cause the IoT SDK to link against your system's existing libcrypto, instead of building its own copy.

Samples

Samples README

Getting Help

The best way to interact with our team is through GitHub. You can open a discussion for guidance questions or an issue for bug reports, or feature requests. You may also find help on community resources such as StackOverFlow with the tag #aws-iot or if you have a support plan with AWS Support, you can also create a new support case.

Please make sure to check out our resources too before opening an issue:

License

This library is licensed under the Apache 2.0 License.

Latest released version: v1.33.0

aws-iot-device-sdk-cpp-v2's People

Contributors

alfred2g avatar bretambrose avatar davidogunsaws avatar fthompsonaws avatar fufranci avatar giordzaws avatar gocarlos avatar graebm avatar gregbreen avatar jmklix avatar jonathanhenson avatar jpeddicord avatar justin8 avatar justinboswell avatar kaibalopez avatar lwilkovich avatar marcoemorais-aws avatar massi-ang avatar mikedombo avatar ravichandhrarean avatar rccarper avatar rpcme avatar sbstevek avatar sfod avatar somayab avatar tingdaok avatar twistedtwigleg avatar xiazhvera avatar yourslab avatar zayeshaataws avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aws-iot-device-sdk-cpp-v2's Issues

Greengrass discovery sample appears to not be working after latest updates

I have deployed GreenGrass service v1.9.2 on a raspberry pi with the device sdk cpp v2 for a proof of concept of this technology and was able to successfully discover and publish to the GreenGrass group setup on the AWS cloud account (using commit 42ec5c5).

Since the latest version and code changes (14 days ago) i am unable to publish and am getting the following error: "Connection setup failed with error libaws-c-common: AWS_ERROR_FILE_INVALID_PATH, Invalid file path". This message is printed out from the code when it is unable to make a new mqtt client connection. I checked the paths that i am passing to the connection but cannot determine which one, if any are incorrect, since the same paths are passed in the previous commit of the code and it works (if that is what the error is referring to).

I also have a question about the distinction of the discover connection and the mqtt connection which i believe are on ports 8443 and 8883 respectively. If this is the case why is the mqtt connection created within the scope of the discover? I assume since discover is supposed to be once off that in a normal situation you would discover once and then create the mqtt connection outside of the scope of the discover connection or does this have to be done so that the pub/sub goes through GreenGrass (and not direct from the sdk to cloud)?

Could you please assist as soon as possible, as this is quite urgent.

IoT Core - SDK never sends OnResume() callback if mqtt keep alive interval expires

We tested the SDK for IoT Core (not Greengrass).

  1. We created an MQTT connection
  2. Removed the ethernet cable on device and waited till we got the the $aws/events/presence/disconnected/D17 on AWS IoT core console
  3. Plugged the ethernet cable back
  4. mqtt connection callback OnResume() never got called back. Connection state remains 1 (Connecting) forever.

Greengrass support

We got sample/shadow_sync working for IoT Core
Will the same sample work for Greengrass core if we change the endpoint ?

Thanks
Amit Gupta
Hitachi Vantara

cmake related issue HttpRequestResponse.h Can't be found

Operating System: Ubuntu 16.04

GCC: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)

Cmake: 3.5.1

I followed the Build from Source directions outlined in the README.md and came across this error after firing off the last step, cmake --build . --target install

Scanning dependencies of target Discovery-cpp [ 80%] Building CXX object discovery/CMakeFiles/Discovery-cpp.dir/source/GGGroup.cpp.o [ 82%] Building CXX object discovery/CMakeFiles/Discovery-cpp.dir/source/DiscoveryClient.cpp.o /home/user/aws/iot-sdk-v2/aws-iot-device-sdk-cpp-v2/discovery/source/DiscoveryClient.cpp:18:46: fatal error: aws/crt/http/HttpRequestResponse.h: No such file or directory compilation terminated. discovery/CMakeFiles/Discovery-cpp.dir/build.make:86: recipe for target 'discovery/CMakeFiles/Discovery-cpp.dir/source/DiscoveryClient.cpp.o' failed make[2]: *** [discovery/CMakeFiles/Discovery-cpp.dir/source/DiscoveryClient.cpp.o] Error 1 CMakeFiles/Makefile2:195: recipe for target 'discovery/CMakeFiles/Discovery-cpp.dir/all' failed make[1]: *** [discovery/CMakeFiles/Discovery-cpp.dir/all] Error 2 Makefile:127: recipe for target 'all' failed make: *** [all] Error 2

This header file isn't found in the /include/ directories. Here's what I find after running cmake.

  • /aws/iot-sdk-v2/build/include/aws/crt/http
  • /aws/iot-sdk-v2/build/include/aws/crt/http/HttpConnectionManager.h
  • /aws/iot-sdk-v2/build/include/aws/crt/http/HttpConnection.h
  • /aws/iot-sdk-v2/build/include/aws/crt/http/HttpRequest.h
  • /aws/iot-sdk-v2/aws-crt-cpp/include/aws/crt/http
  • /aws/iot-sdk-v2/aws-crt-cpp/include/aws/crt/http/HttpConnectionManager.h
  • /aws/iot-sdk-v2/aws-crt-cpp/include/aws/crt/http/HttpConnection.h
  • /aws/iot-sdk-v2/aws-crt-cpp/include/aws/crt/http/HttpRequest.h

DiscoveryClient.cpp references a HttpClientConnectionOptions struct that I see in HttpConnection.h, so maybe that's the correct reference. Looks like the include was changed here #56.

Otherwise, I can't figure this out, and if I've made an obvious error in attempting to build from source, any guidance would be greatly appreciated.

How to construct UpdateShadowRequest from json string

Please refer to update_digital_twin method we wrote to encapsulate updating shadow from our device.

I have marked 2 lines in our code.

The issue is : when new_json is sent as {"state":{"reported":{"trigger":1}}}
The 1st line shows the logger as
Jun 10 19:47:31 D16 device_agent: update_digital_twin:Shadow update request {"state":{"reported":{"trigger":1}}}
Which is correct

But the 2nd line shows logger as
Jun 10 19:47:31 D16 device_agent: update_digital_twin:UpdateShadowRequest {"state":{}}
This is incorrect.
Seems our understanding of how to construct UpdateShadowRequest.State from a valid json string for reported or desired state of shadow is not correct. PLEASE HELP ...

int CAwsSdkInterface::update_digital_twin(string new_json) {
	**1st line** spdlog::debug("update_digital_twin:Shadow update request {0}" , new_json);
	if (new_json.empty()) { 
		return FAILURE_UPDATE_EMPTY_STRING; 
	}
	JsonObject doc(new_json.c_str());
	if (!doc.WasParseSuccessful()) { 
		spdlog::error("Failed to parse json");
		return FAILURE_UPDATE_JSON_PARSE; 
	}
	std::condition_variable conditionPub;
	std::atomic<bool> updateSuccess(false);
	std::atomic<bool> updateFailed(false);
	
	std::mutex shadow_response_mutex;

	int rc = get_connection();
	if (rc != SUCCESS) { return rc; }

	UpdateShadowRequest request;
	request.ThingName = thingName.c_str();
	request.State = std::move(doc);
	//So far handleAccept or handleReject has not come into play till agent calls PublishUpdateShadow
	auto onPubAck = [&](int ioErr) {
		{
			std::unique_lock<std::mutex> lock(shadow_response_mutex);
			if (AWS_OP_SUCCESS == ioErr) {
				spdlog::debug("Shadow Update success");
				updateSuccess = true;
			}
			else {
				spdlog::debug("Shadow Update failed with error {0}", ioErr);
				updateFailed = true;
			}
		}
		conditionPub.notify_one();
	};

	// publishing request.State to this shadow/update topic
	// $aws/things/thingName/shadow/update
	{
		std::unique_lock<std::mutex> lock(shadow_response_mutex);
		spdlog::debug("PublishUpdateShadow");
		JsonObject doc2;
		request.SerializeToObject(doc2);
		**2nd line** spdlog::debug("update_digital_twin:UpdateShadowRequest {0}", doc2.View().WriteReadable().c_str());
		//todo : Possible optimization to allow callbacks instead of locks
		bool v3 = p_shadow_client->PublishUpdateShadow(request, pubSubQos, std::move(onPubAck));
		if (!v3) {
			spdlog::error("Failed to update shadow");
			return FAILURE_UPDATE_ACK_SUBSCRIBE;
		}
		//Initial publish
		conditionPub.wait(lock, [&]() {
			return updateSuccess.load() || updateFailed.load();
		});
		spdlog::debug("PublishUpdateShadow completed");
	}
	return (updateSuccess)? SUCCESS : FAILURE;
}

What is keep_alive_timeout_sec ?

Please refer to socket options that are used in mqttClient->NewConnection (Refer to code snippet below)
What does it do ?
How does it differs from keep_alive_interval ?

socketOptions.connect_timeout_ms = 3000;
socketOptions.domain = AWS_SOCKET_IPV4;
socketOptions.type = AWS_SOCKET_STREAM;
socketOptions.keep_alive_interval_sec = this->mqttConfiguration.keep_alive_interval_sec; //30
**socketOptions.keep_alive_timeout_sec = this->mqttConfiguration.keep_alive_interval_sec; //30**
socketOptions.keepalive = true;

///*
	// * Now create a connection object. Note: This type is move only
	// * and its underlying memory is managed by the client.
	// */
	mqttConnection = mqttClient->NewConnection(endpoint.c_str(), port, socketOptions, connectionOptions);

	if (!*mqttConnection)
	{
		fprintf(stderr, "MQTT Connection Creation failed with error %s\n", ErrorDebugString(mqttConnection->LastError()));
		return MQTT_CONNECTION_CREATION_FAILED;
	}

/*
	 * Connect -> Persistent session
	 When a client requests the server to hold session data, the client is responsible for storing the following information:
	 All messages in a QoS 1 or 2 flow, that are not yet confirmed by the broker.
	 All QoS 2 messages received from the broker that are not yet completely acknowledged.
	*/
	if (!mqttConnection->Connect(clientId.c_str(), false, mqttConfiguration.keep_alive_interval_sec))
	{
		fprintf(stderr, "MQTT Connection failed with error %s\n", ErrorDebugString(mqttConnection->LastError()));
		return FAILURE_CONNECT;
	}

tcp dump for SDK crash

@JonathanHenson please look at the tcp dump for the sdk crash
I have highlighted the crash timestamp 14:52:00.049075

Our AWS SDK agent logger
Jun 12 14:52:00 D16 device_agent[5056]: [14:52:00:039231472: +00:00] [---W---] [thread 5059] Connection onInterrupt
Jun 12 14:52:00 D16 device_agent[5056]: [14:52:00:039584632: +00:00] [---W---] [thread 5059] Connection Interrupted with Error libaws-c-mqtt: AWS_ERROR_MQTT_TIMEOUT, Time limit between request and response has been exceeded.
Jun 12 14:52:00 D16 device_agent: Connection onInterrupt
Jun 12 14:52:00 D16 device_agent: Connection Interrupted with Error libaws-c-mqtt: AWS_ERROR_MQTT_TIMEOUT, Time limit between request and response has been exceeded.
Jun 12 14:52:00 D16 device_agent[5103]: [14:52:00:465911675: +00:00] [---I---] [thread 5103] Starting HV agent service...

OnResume() did not get called

TCP dump
14:51:53.013309 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [.], ack 400, win 262, options [nop,nop,TS val 3932742808 ecr 19397442], length 0
14:51:55.044841 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [P.], seq 400:500, ack 1, win 1000, options [nop,nop,TS val 19397950 ecr 3932742808], length 100
14:51:55.045240 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [.], ack 500, win 262, options [nop,nop,TS val 3932744840 ecr 19397950], length 0
14:51:57.037940 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [P.], seq 500:531, ack 1, win 1000, options [nop,nop,TS val 19398449 ecr 3932744840], length 31
14:51:57.038223 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [.], ack 531, win 262, options [nop,nop,TS val 3932746833 ecr 19398449], length 0
14:51:57.038443 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [P.], seq 1:32, ack 531, win 262, options [nop,nop,TS val 3932746833 ecr 19398449], length 31
14:51:57.038606 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [.], ack 32, win 1000, options [nop,nop,TS val 19398449 ecr 3932746833], length 0
14:51:57.106527 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [P.], seq 531:631, ack 32, win 1000, options [nop,nop,TS val 19398466 ecr 3932746833], length 100
14:51:57.147968 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [.], ack 631, win 262, options [nop,nop,TS val 3932746943 ecr 19398466], length 0
14:51:59.044234 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [P.], seq 631:731, ack 32, win 1000, options [nop,nop,TS val 19398950 ecr 3932746943], length 100
14:51:59.044441 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [.], ack 731, win 262, options [nop,nop,TS val 3932748839 ecr 19398950], length 0
14:52:00.049075 IP 10.0.0.4.35628 > api-amit.5gdcs.com.8883: Flags [S], seq 4008811436, win 29200, options [mss 1460,sackOK,TS val 19399201 ecr 0,nop,wscale 6], length 0
14:52:00.049371 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35628: Flags [S.], seq 3427409218, ack 4008811437, win 28960, options [mss 1460,sackOK,TS val 3932749844 ecr 19399201,nop,wscale 7], length 0
14:52:00.049615 IP 10.0.0.4.35628 > api-amit.5gdcs.com.8883: Flags [.], ack 1, win 457, options [nop,nop,TS val 19399202 ecr 3932749844], length 0
14:52:00.063295 IP 10.0.0.4.35628 > api-amit.5gdcs.com.8883: Flags [F.], seq 1, ack 1, win 457, options [nop,nop,TS val 19399205 ecr 3932749844], length 0
14:52:00.063903 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35628: Flags [.], ack 2, win 227, options [nop,nop,TS val 3932749859 ecr 19399205], length 0
14:52:00.064127 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35628: Flags [F.], seq 1, ack 2, win 227, options [nop,nop,TS val 3932749859 ecr 19399205], length 0
14:52:00.064300 IP 10.0.0.4.35628 > api-amit.5gdcs.com.8883: Flags [.], ack 2, win 457, options [nop,nop,TS val 19399205 ecr 3932749859], length 0
14:52:00.075802 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [F.], seq 731, ack 32, win 1000, options [nop,nop,TS val 19399208 ecr 3932748839], length 0
14:52:00.076227 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [P.], seq 32:63, ack 732, win 262, options [nop,nop,TS val 3932749871 ecr 19399208], length 31
14:52:00.076466 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [R], seq 3125822068, win 0, length 0
14:52:00.076541 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35590: Flags [F.], seq 63, ack 732, win 262, options [nop,nop,TS val 3932749871 ecr 19399208], length 0
14:52:00.076634 IP 10.0.0.4.35590 > api-amit.5gdcs.com.8883: Flags [R], seq 3125822068, win 0, length 0
14:52:00.640201 IP 10.0.0.4.35630 > api-amit.5gdcs.com.8883: Flags [S], seq 37084101, win 29200, options [mss 1460,sackOK,TS val 19399349 ecr 0,nop,wscale 6], length 0
14:52:00.640452 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35630: Flags [S.], seq 1148298085, ack 37084102, win 28960, options [mss 1460,sackOK,TS val 3932750435 ecr 19399349,nop,wscale 7], length 0
14:52:00.640642 IP 10.0.0.4.35630 > api-amit.5gdcs.com.8883: Flags [.], ack 1, win 457, options [nop,nop,TS val 19399349 ecr 3932750435], length 0
14:52:00.650125 IP 10.0.0.4.35630 > api-amit.5gdcs.com.8883: Flags [P.], seq 1:147, ack 1, win 457, options [nop,nop,TS val 19399352 ecr 3932750435], length 146
14:52:00.650530 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35630: Flags [.], ack 147, win 235, options [nop,nop,TS val 3932750445 ecr 19399352], length 0
14:52:00.657672 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35630: Flags [.], seq 1:1449, ack 147, win 235, options [nop,nop,TS val 3932750452 ecr 19399352], length 1448
14:52:00.657875 IP 10.0.0.4.35630 > api-amit.5gdcs.com.8883: Flags [.], ack 1449, win 502, options [nop,nop,TS val 19399354 ecr 3932750452], length 0
14:52:00.657972 IP api-amit.5gdcs.com.8883 > 10.0.0.4.35630: Flags [P.], seq 1449:1749, ack 147, win 235, options [nop,nop,TS val 3932750452 ecr 19399352], length 300

Build fails

Fail to build from scratch.

In file included from /home/kevin/aws_test_build/install/include/aws/crt/Types.h:17:0,
from /home/kevin/aws_test_build/install/include/aws/crt/Api.h:16,
from /home/kevin/aws_test_build/aws-iot-device-sdk-cpp-v2/samples/jobs/describe_job_execution/main.cpp:15:
/home/kevin/aws_test_build/install/include/aws/crt/Optional.h: In instantiation of ‘Aws::Crt::Optional& Aws::Crt::Optional::operator=(U&&) [with U = Aws::Crt::UUID; T = std::__cxx11::basic_string<char, std::char_traits, Aws::Crt::StlAllocator >]’:
/home/kevin/aws_test_build/aws-iot-device-sdk-cpp-v2/samples/jobs/describe_job_execution/main.cpp:288:49: required from here
/home/kevin/aws_test_build/install/include/aws/crt/Optional.h:59:30: error: ambiguous overload for ‘operator=’ (operand types are ‘std::__cxx11::basic_string<char, std::char_traits, Aws::Crt::StlAllocator >’ and ‘Aws::Crt::UUID’)
*m_value = std::forward(u);
^
In file included from /usr/include/c++/5/string:52:0,
from /usr/include/c++/5/stdexcept:39,
from /usr/include/c++/5/array:38,
from /usr/include/c++/5/tuple:39,
from /usr/include/c++/5/functional:55,
from /usr/include/c++/5/memory:79,
from /home/kevin/aws_test_build/install/include/aws/crt/StlAllocator.h:17,
from /home/kevin/aws_test_build/install/include/aws/crt/Types.h:18,
from /home/kevin/aws_test_build/install/include/aws/crt/Api.h:16,
from /home/kevin/aws_test_build/aws-iot-device-sdk-cpp-v2/samples/jobs/describe_job_execution/main.cpp:15:
/usr/include/c++/5/bits/basic_string.h:550:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(const std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits; _Alloc = Aws::Crt::StlAllocator]
operator=(const basic_string& __str)
^
/usr/include/c++/5/bits/basic_string.h:569:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(_CharT) [with _CharT = char; _Traits = std::char_traits; _Alloc = Aws::Crt::StlAllocator]
operator=(_CharT __c)
^
/usr/include/c++/5/bits/basic_string.h:587:7: note: candidate: std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator=(std::__cxx11::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits; _Alloc = Aws::Crt::StlAllocator]
operator=(basic_string&& __str)
^
samples/jobs/describe_job_execution/CMakeFiles/describe-job-execution.dir/build.make:62: recipe for target 'samples/jobs/describe_job_execution/CMakeFiles/describe-job-execution.dir/main.cpp.o' failed
make[2]: *** [samples/jobs/describe_job_execution/CMakeFiles/describe-job-execution.dir/main.cpp.o] Error 1
CMakeFiles/Makefile2:250: recipe for target 'samples/jobs/describe_job_execution/CMakeFiles/describe-job-execution.dir/all' failed
make[1]: *** [samples/jobs/describe_job_execution/CMakeFiles/describe-job-execution.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Shadow sample: AWS_ERROR_FILE_INVALID_PATH

When I try to run the shadow sample of release v1.3 on emb. linux target, I get:

Client Configuration initialization failed with error aws-c-common: AWS_ERROR_FILE_INVALID_PATH, Invalid file path.

tried to run it with:
./shadow-sync --endpoint MYENDPOINT.iot.eu-west-1.amazonaws.com --key "/data/private.pem" --cert "/data/certificate.pem" --thing_name "MY-SECRET-THINGNAME" --shadow_property testSDK

Private Key and cert are definitely correct and located in provided paths, since I use the same files with SDK v1.

inserted some fprintf debug statements in main.cpp to print decoded cmd line args: both filepaths are successfully decoded in local member strings...

endpoint = s_getCmdOption(argv, argv + argc, "--endpoint");

Unable to build on linux.

Following the instructions, I try to run the cmake command provided:
cmake -DCMAKE_INSTALL_PREFIX=/.oelocal/x86_64 -DCMAKE_PREFIX_PATH=/.oelocal/x86_64/ -DBUILD_SHARED_LIBS=ON -DBUILD_DEPS=ON ../aws-crt-cpp

This is the output I get
"""
CMake Error at CMakeLists.txt:26 (include):
include could not find load file:
AwsCFlags

CMake Error at CMakeLists.txt:27 (include):
include could not find load file:
AwsSharedLibSetup

CMake Error at CMakeLists.txt:28 (include):
include could not find load file:
AwsSanitizers

CMake Error at /usr/share/cmake-3.14/Modules/CMakeFindDependencyMacro.cmake:48 (find_package):
By not providing "FindLibCrypto.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"LibCrypto", but CMake did not find one.
Could not find a package configuration file provided by "LibCrypto" with
any of the following names:
LibCryptoConfig.cmake
libcrypto-config.cmake

Add the installation prefix of "LibCrypto" to CMAKE_PREFIX_PATH or set
"LibCrypto_DIR" to a directory containing one of the above files. If
"LibCrypto" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
/usr/lib64/s2n/cmake/s2n-config.cmake:3 (find_dependency)
CMakeLists.txt:168 (find_package)

"""
Is there something I am missing from the instructions?

Publish fail after loss of connection/wifi

Hi

We have an MQTT agent running on debian linux that publishes data to Greengrass core topic.
We have observed that the publish method does not works if the device looses ethernet connection /wifi and then regains the connection.
After the wifi/ethernet connectivity is back, why does the publish not work ?
Our mqtt connection is a single connection that we construct throughout the lifetime of the agent , and we expect that after each cycle of onInterrupt/OnResume the publish should work.

Thanks
Amit Gupta

implicit declaration of function ‘BN_GF2m_mod_mul’

I'm trying to build on Fedora 30 with OpenSSL 1.1.1c and am getting the following error:

/home/ryan/Source/Repos/aws-iot-sdk-c++/aws-crt-cpp-build/deps/build/src/S2N/pq-crypto/bike/openssl_utils.c: In function ‘ossl_cyclic_product’:
/home/ryan/Source/Repos/aws-iot-sdk-c++/aws-crt-cpp-build/deps/build/src/S2N/pq-crypto/bike/openssl_utils.c:46:8: error: implicit declaration of function ‘BN_GF2m_mod_mul’; did you mean ‘BN_mod_mul’? [-Werror=implicit-function-declaration]
   46 |    if (BN_GF2m_mod_mul(r, a, b, m, bn_ctx) == 0) {
      |        ^~~~~~~~~~~~~~~
      |        BN_mod_mul
/home/ryan/Source/Repos/aws-iot-sdk-c++/aws-crt-cpp-build/deps/build/src/S2N/pq-crypto/bike/openssl_utils.c: In function ‘ossl_add’:
/home/ryan/Source/Repos/aws-iot-sdk-c++/aws-crt-cpp-build/deps/build/src/S2N/pq-crypto/bike/openssl_utils.c:132:8: error: implicit declaration of function ‘BN_GF2m_add’ [-Werror=implicit-function-declaration]
  132 |    if (BN_GF2m_add(r, a, b) == 0) {
      |        ^~~~~~~~~~~
cc1: all warnings being treated as errors
gmake[5]: *** [CMakeFiles/s2n.dir/build.make:414: CMakeFiles/s2n.dir/pq-crypto/bike/openssl_utils.c.o] Error 1
gmake[4]: *** [CMakeFiles/Makefile2:73: CMakeFiles/s2n.dir/all] Error 2
gmake[3]: *** [Makefile:130: all] Error 2
gmake[2]: *** [CMakeFiles/S2N.dir/build.make:113: build/src/S2N-stamp/S2N-build] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:298: CMakeFiles/S2N.dir/all] Error 2
gmake: *** [Makefile:84: all] Error 2
CMake Error at CMakeLists.txt:80 (message):
  Failed to build aws crt libraries.


-- Configuring incomplete, errors occurred!

Some questions about the API capabilities

Hello there, AWS-IOT team, keep up the great work!

In my team, we (plan) on using this version of the API after we've dabbled with the old C-API.
We're having a few misunderstanding regarding what the this API is capable of:

  1. In the pub-sub capabilities, in the old C API, you yield in order to receive messages you subscribed to their topic, but you can't do anything in the meanwhile. while you're yielding, you can't subscribe to new topics nor request/delete the device shadow.

This API works with websockets and works a bit differently : in this API - can you listen to new messages while being able to do other things? it's unclear to us. Ideally, we would like to receive messages in the background (by leaving a callback for the new message) and be able to publish messages, manipulate device shadow, etc.

  1. Device shadow: is there a "push" notification for device shadow messages? Ideally, we would like our mobile app to update the device shadow, and other mobile apps, who are logged to the same user will receive a notification that the device shadow was updated/deleted and react/show the new update data.

the closest thing to what we want is the delta callback - when you update the device shadow the server returns a delta JSON to the SDK. but from my understanding, this callback is invoked by the updating SDK and not "globally".

does this new C++ API provides the capabilities of achieving what I described above? if not, is there a way to implement the above in this API?

thanks!

AWS SDK Build failure

Hi
We took latest code from AWS SDK CPP V2 today and it fails to build.
Please help urgently as we are stuck testing and taking forward some critical issues pending for our project.

/home/agupta/deviceagentcpp-bin/lib/libaws-c-http.a(hpack.c.o): In function aws_hpack_context_new': hpack.c:(.text+0xd3a): undefined reference to aws_huffman_encoder_init'
hpack.c:(.text+0xd44): undefined reference to aws_huffman_decoder_init' /home/agupta/deviceagentcpp-bin/lib/libaws-c-http.a(hpack.c.o): In function aws_hpack_encode_string':
hpack.c:(.text+0x1062): undefined reference to `aws_huffman_encode'
collect2: error: ld returned 1 exit status
iot_layer/tests/CMakeFiles/test-iot_layer.dir/build.make:137: recipe for target 'iot_layer/tests/test-iot_layer' failed
make[2]: *** [iot_layer/tests/test-iot_layer] Error 1
CMakeFiles/Makefile2:1727: recipe for target 'iot_layer/tests/CMakeFiles/test-iot_layer.dir/all' failed
make[1]: *** [iot_layer/tests/CMakeFiles/test-iot_layer.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

Thanks
Amit Gupta

When it will be Generally Available

Hi,

We are planning to use this v2 SDK for our production code for greengrass, but before that we want to clarify these things,

  1. Will this supports to connect to greengrass core?

  2. When it will be Published as generally available (we are assuming with in next 3 months)?

  3. Are you suggest us to use this for production?

We are eagerly waiting for your response.

Thank you.

Regards,
Ravichandhra Palla

Not able to build

Hi,

I am not able to build by following this given procedure in README.md

git clone --branch v0.1.1 https://github.com/awslabs/aws-crt-cpp.git
git clone https://github.com/awslabs/aws-iot-device-sdk-cpp-v2.git
mkdir aws-crt-cpp-build
cd aws-crt-cpp-build
cmake -DCMAKE_INSTALL_PREFIX="<path to where you install>" -DCMAKE_PREFIX_PATH="<path to where you install>" -DBUILD_SHARED_LIBS=ON -DBUILD_DEPS=ON ../aws-crt-cpp
<invoke build command make, msbuild, ninja etc....> install
cd ..
mkdir aws-iot-device-sdk-cpp-v2
cd aws-iot-device-sdk-cpp-v2
cmake -DCMAKE_INSTALL_PREFIX="<path to where you install>" -DCMAKE_PREFIX_PATH="<path to where you install>" -DBUILD_SHARED_LIBS=ON ../aws-iot-device-sdk-cpp-v2
<invoke build command make, msbuild, ninja etc....> install

There are two mistakes exists in the given procedure,
1. (there is no v0.1.1 branch existed)
git clone --branch v0.1.1 https://github.com/awslabs/aws-crt-cpp.git

2. (I think it should be aws-iot-device-sdk-cpp-v2-build)

 mkdir aws-iot-device-sdk-cpp-v2
 cd aws-iot-device-sdk-cpp-v2

I modified those two mistakes but not able build it successfully.

I couldn't understand what are these two CMAKE_PREFIX_PATH , CMAKE_INSTALL_PREFIX . It will be really helpful if you provide the description of those variables.

I tried to build it on Linux

Thank you.

Regards,
Ravichandhra Palla

Keep alive interval issue

We set the keep alive interval for both socket and mqtt connection to 30s
Reason - When a device looses WiFi we want a disconnected lifecycle event as quickly as possible
But we still see connection getting disconnected around 45s.

In previous AWS C SDK 3.1 - the SDK used to send periodic pings to keep the connection alive forever.

Question 1) Has this been removed in aws-iot-device-sdk-cpp-v2 ?

Question 2) Does our client code need to send periodic pings if we are not publishing anything within keep alive interval ?

if (!mqttConnection->Connect(clientId.c_str(), false, 30))
	{
		fprintf(stderr, "MQTT Connection failed with error %s\n", ErrorDebugString(mqttConnection->LastError()));
		return FAILURE_CONNECT;
	}

Deterministic segmentation fault - ByteBufDelete

Segmentation fault highlighted

int CAwsSdkInterface::publish_async(const char *topic, uint8_t buffer, size_t length) {
//for unit tests workflow
int rc = get_connection();
if (rc != SUCCESS) {
return rc;
}
ByteBuf payload = ByteBufNewCopy(DefaultAllocator(), buffer, length);
/

* This will be invoked upon the completion of Publish
/
auto onOpComplete = [&payload](Mqtt::MqttConnection& conn, uint16_t packetId, int errorCode)
{
if (errorCode == AWS_OP_SUCCESS) {
spdlog::debug("Publish Operation on packetId {0} Succeeded", (int)packetId);
}
else {
spdlog::error("Publish Operation failed with error {0}", aws_error_debug_str(errorCode));
}
ByteBufDelete(payload);
};
/

* Publish our message.
*/
auto packetId = mqttConnection->Publish(topic, pubSubQos, false, payload, std::move(onOpComplete));
(void)packetId;

return SUCCESS;

}

cmake build failure

Changes in the API is not reflected in sample programs
Refer to
\aws_sdk\aws-iot-device-sdk-cpp-v2\samples\jobs\describe_job_execution\main.cpp
Line# 163 fails build
Io::ClientBootstrap bootstrap(eventLoopGroup);

Severity Code Description Project File Line Suppression State
Error no matching function for call to ‘Aws::Crt::Io::ClientBootstrap::ClientBootstrap(Aws::Crt::Io::EventLoopGroup&)’ C:\appdev\src\deviceagentcpp\aws_sdk\aws-iot-device-sdk-cpp-v2\CMakeLists.txt C:\appdev\src\deviceagentcpp\aws_sdk\aws-iot-device-sdk-cpp-v2\samples\jobs\describe_job_execution\main.cpp 163

aws_sdk\aws-iot-device-sdk-cpp-v2\samples\shadow\shadow_sync\main.cpp
Line# 203 fails build

Please reflect the new api changes to samples.

Mqtt::ReturnCode Bug in sample

Hi @graebm / @JonathanHenson ,

the recent updates,

  1. The Mqtt::ConnectionState enum has been removed from the latest version of the SDK
  2. Intoruduced Mqtt::ReturnCode

If you look into this sample code both,

  1. In onConnectionCompleted callback lambda it is treating if there is no errorCode means connection is successful and just printing the connection completed message with returnCode
  2. it is assuming that the returnCode is always gives succes but If we look into the mqtt.h file there is a possibility of getting returnCode with different errors(We tested it we got 4/5 sometimes)
  3. Our further business logic depends on this initial mqtt connection status, So could you please look into this.
  4. And also can you add onResumed , onInterrupted methods support for this sample
/* Result of a connect request [MQTT-3.2.2.3]. */
enum aws_mqtt_connect_return_code {
    AWS_MQTT_CONNECT_ACCEPTED,
    AWS_MQTT_CONNECT_UNACCEPTABLE_PROTOCOL_VERSION,
    AWS_MQTT_CONNECT_IDENTIFIER_REJECTED,
    AWS_MQTT_CONNECT_SERVER_UNAVAILABLE,
    AWS_MQTT_CONNECT_BAD_USERNAME_OR_PASSWORD,
    AWS_MQTT_CONNECT_NOT_AUTHORIZED,
    /* reserved = 6 - 255 */
};
    /*
     * This will execute when an mqtt connect has completed or failed.
     */
    auto onConnectionCompleted = [&](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) {
        if (errorCode)
        {
            fprintf(stdout, "Connection failed with error %s\n", ErrorDebugString(errorCode));
            std::lock_guard<std::mutex> lockGuard(mutex);
            connectionSucceeded = false;
        }
        else
        {
            fprintf(stdout, "Connection completed with return code %d\n", returnCode);
            connectionSucceeded = true;
        }
        {
            std::lock_guard<std::mutex> lockGuard(mutex);
            connectionCompleted = true;
        }
        conditionVariable.notify_one();
    };

Thank you.

Regards,
Ravichandhra Palla.

What explains OnInterrupt and OnResume callbacks within a ms

Jun 10 18:25:55 D16 device_agent[8532]: [18:25:55:317425191: +00:00] [---W---] [thread 8535] Connection onInterrupt
Jun 10 18:25:55 D16 device_agent[8532]: [18:25:55:573024905: +00:00] [---I---] [thread 8535] Connection onResume

I took the latest SDK code , and we see the callbacks 300ms apart .
What can possibly explain this ?

Can't cmake configure the project v1.4.3 (or older) with Visual Studio 2017/2019

I cannot run cmake configure as instructed in README.md for aws-iot-device-sdk-cpp-v2 with the tag v1.4.3 (or older) using Visual Studio 2019 and Cmake 3.15.2 with the command cmake -DCMAKE_INSTALL_PREFIX="c:/data/aws-iot-device-sdk-cpp-v2-install" -DBUILD_DEPS=ON c:/data/aws-iot-device-sdk-cpp-v2, because the cmake configure step fails while building aws-crt-cpp with a number of errors like:

C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\14.24.28218\include\vector(1262,1): 
warning C4530: C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc 
[C:\Data\aws-iot-device-sdk-cpp-v2-build\deps\build\src\AwsCrtCpp-build\aws-crt-cpp.vcxproj] 
[C:\Data\aws-iot-device-sdk-cpp-v2-build\deps\AwsCrtCpp.vcxproj]

However, if manually clone and cmake configure aws-crt-cpp independently, it works fine!

Comparing the build directories of the manually configured aws-crt-cpp and the failing aws-crt-cpp automatically configured by the sdk v2 depencency chain, in their CMakeCache.txt files I can see that the manually configured aws-crt-cpp has the env variable CMAKE_CXX_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3 /GR /EHsc, but in the dependency chain configured CMakeCache.txt the variable instead is an empty string CMAKE_CXX_FLAGS:STRING= .

Unless I'm doing something horribly wrong, I suspect the problem is that aws-iot-device-sdk-cpp-v2/CMakeLists.txt on line 71 (just before mixing tabs and spaces for indentation!) uses execute_process() to run cmake configure for aws-crt-cpp with the option -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}, which sets the value of CMAKE_CXX_FLAGS of aws-crt-cpp to be an empty string instead undefined, and apparently if it's undefined it eventually gets replaced with the cmake default values.

Removing the option -DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS} from the aws-iot-device-sdk-cpp-v2/CMakeLists.txt fixes the cmake configure step errors, at least for me.

As for a good solution, I'm not sure what would be a good way pass cmake env variables but only when defined. One option might be the the new FetchContent() (https://cmake.org/cmake/help/latest/module/FetchContent.html) cmake command, which might be a good way to pass all env variables automatically instead of manually passing command line strings with execute_process().

P.S.
I believe that when @kankri in awslabs/aws-c-mqtt#116 mentioned that his build of sdk-cpp-v2 fails on windows, he referred to this issue, as he was also having this same build issue before the christmas holidays.

Connection after discovery does not resume after connection loss

I am currently using commit 42ec5c of the C++ v2. SDK with greengrass core v1.9.2. I am unable to use the latest SDK because the discovery does not work (i am waiting for a reply on the thread "Greengrass discovery sample appears to not be working after latest updates #53").

With regards to testing the AWS connection, i have run through some test cases and found that when the connection drops and then resumes, i get a segmentation fault.

So i get the following message printed out from the code in the connection->OnConnectionInterrupted function:
"Connection Interrupted with error libaws-c-common: AWS_ERROR_SUCCESS, Success.".
In most cases i get a segmentation fault directly after that message.

In one case i received the following also after the above message, and then the application aborted:
"Fatal error condition occurred in /tmp/aws_device_sdk/deps/aws-c-io/source/channel.c:261: channel->channel_state == AWS_CHANNEL_SHUT_DOWN".

I would like to provide more debug information by switching on the api logging (InitializeLogging) but that is only available in the newer versions of the SDK which doesnt work for me.

This is quite a concerning issue for our use case as the code should recover without the application crashing.

Any ideas on what is causing the fault and how to fix it?

Proxy Support

In certain environments, proxy support is needed to allow communication to the cloud, as even direct connections over 443 may be blocked.

There was a pull request in the v1 client that added this but it has never been merged (aws/aws-iot-device-sdk-cpp#9).

Connection state does not changes to "Disconnected"

We wrote a unit test to check effect of calling Disconnect() on mqtt connection
Even after a successful callback - OnDisconnect() the state of mqtt connection shows value 3 (Connected" and not disconnected

/*
Test disconnect state
*/
TEST_F(CAwsSdkInterfaceTest, test_publish_disconnect_gg) {
aws_sdk_gg = new CAwsSdkInterface(mqtt_configuration);
int initialization_status = aws_sdk_gg->initialize_mqtt_client(cert, thing, mqtt_configuration, shadowUpdateCallback);
std::cout << "initialize_mqtt_client: " << initialization_status << std::endl;
const std::string ping_topic = topic_prefix + "ping/" + thing.thingName;
std::ostringstream ping_ostr;
ping_ostr << std::setprecision(10) << "{"ping": {"iteration": "1 of 1"}}";
std::string s = ping_ostr.str();
std::cout << "before publish" << std::endl;
int rc = aws_sdk_gg->publish(ping_topic.c_str(), (uint8_t )s.c_str(), s.length());
std::cout << "after publish" << std::endl;
EXPECT_EQ(SUCCESS, rc);
int rc2 = aws_sdk_gg->disconnect_connection();
std::cout << "after disconnect" << std::endl;
int rc3 = aws_sdk_gg->is_mqtt_connection_alive();
EXPECT_EQ(FAILURE, rc);

delete aws_sdk_gg;
std::cout << "test ends" << std::endl;
}
/

* Invoked when a disconnect message has completed.
*/
auto onDisconnect = [this](Mqtt::MqttConnection &conn) {
{
std::unique_lockstd::mutex uniqueLock(mutexConnection);
spdlog::warn("mqtt connection disconnected Connection state {0}", static_cast(conn.GetConnectionState()));
this->connectionClosed = true;
this->mqttConnection.reset();
}
conditionVariable.notify_one();
};

int CAwsSdkInterface::is_mqtt_connection_alive() {
//get_connection
if (mqttConnection) {
const ConnectionState conn_state = mqttConnection->GetConnectionState();
if (conn_state == ConnectionState::Disconnected) {
return FAILURE;
}
else {
return SUCCESS;
}
}
return FAILURE;
}

[16:55:08:786721571: +00:00] [---I---] [thread 20083] Create new mqtt connection
[16:55:08:794409966: +00:00] [---D---] [thread 20083] get_connection: success=false closed=false
[16:55:08:915379827: +00:00] [---D---] [thread 20084] Connection completed with return code 0
[16:55:08:920121695: +00:00] [---I---] [thread 20084] Connection state 2
[16:55:08:924792148: +00:00] [---D---] [thread 20083] get_connection: success=true closed=false
[16:55:08:926257245: +00:00] [---D---] [thread 20083] add_shadow_subscriptions
[16:55:08:932904618: +00:00] [---D---] [thread 20084] Subscribed for shadow update accepted topic
[16:55:08:936653880: +00:00] [---D---] [thread 20084] Subscribed for shadow update rejected topic
[16:55:08:938244767: +00:00] [---D---] [thread 20083] Publish waiting ...
[16:55:08:942124234: +00:00] [---D---] [thread 20084] Publish Operation on packetId 3 Succeeded
[16:55:08:943416793: +00:00] [---D---] [thread 20083] Publish finish waiting ...success=1 failures=0
after publish
[16:55:08:947682878: +00:00] [---D---] [thread 20083] disconnect_connection: wait completed closed=false
[16:55:08:950022501: +00:00] [---W---] [thread 20084] mqtt connection disconnected Connection state 3
[16:55:08:953752054: +00:00] [---D---] [thread 20083] disconnect_connection: wait completed closed=true
after disconnect
/home/agupta/deviceagentcpp/iot_layer/tests/src/test_CAwsSdkInterface.cpp:397: Failure
Expected equality of these values:
-1
rc
Which is: 0

[16:55:08:961802234: +00:00] [---D---] [thread 20083] cleanup sdk
[16:55:08:963670532: +00:00] [---D---] [thread 20083] bootstrap
[16:55:08:969313050: +00:00] [---D---] [thread 20083] defaultHostResolver
[16:55:08:971145265: +00:00] [---D---] [thread 20083] eventLoopGroup
[16:55:08:972366533: +00:00] [---D---] [thread 20083] tlsCtx
[16:55:08:977521935: +00:00] [---D---] [thread 20083] mqttClient
[16:55:08:978537249: +00:00] [---D---] [thread 20083] cleanup completed
test ends
[ FAILED ] CAwsSdkInterfaceTest.test_publish_disconnect_gg (273 ms)
[----------] 1 test from CAwsSdkInterfaceTest (275 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test suite ran. (282 ms total)
[ PASSED ] 0 tests.
[ FAILED ] 1 test, listed below:
[ FAILED ] CAwsSdkInterfaceTest.test_publish_disconnect_gg

1 FAILED TEST
Tests status: 1

Getting connected state even though disconnect message published to IoT topic

Hi,

to check the state of MQTT Client connection we are making this call for every 10 seconds,
int connectionState = static_cast<int>(mqttConnection->GetConnectionState()

but it is returning 2 - means connected, even though there is no network connected and disconnected message published to IoT life-cycle topic

MqttClient.h
inline ConnectionState GetConnectionState() const noexcept { return m_connectionState; }

is the m_connectionState is updating it's value when connection interrupted/disconnected/resumed?

Thank you.

Regards,
Ravichandhra Palla
Hitachi Vantara
[email protected]

cmake related issue on getting/referring header files path of module IotShadow-cpp

I am encountering errors while trying to build a new executable using cmake with the file "aws-iot-device-sdk-cpp-v2/samples/shadow/shadow_sync/main.cpp".

As prerequisite, I’ve downloaded aws-crt-cpp & aws-iot-device-sdk-cpp-v2 from git, built the libraries using CMake & make (gcc 7.3) in a different folder (e.g. ~/temp/bin)

I’ve copied the CMakeLists.txt (from shadow_sync) and modified to build my project.

It links with IotShadow-cpp, so I’ve used the below line to load the package.
find_package(IotShadow-cpp REQUIRED)

To find the package I’d to add the below lines
list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/IotShadow-cpp/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_INSTALL_PREFIX}/lib/cmake")

I had to rename the file to lower case (iotshadow-cpp-config.cmake) and I figured this out after trying several things!

Now, the package is loaded but include directories are not, causing compilation to fail.

Please advise if I’m missing anything or there is any issue elsewhere. I’m attaching the below files for your review.

Attachments:
New CMakeLists.txt
main.cpp
Original CMakeLists.txt

Immediately disconnected after connect

Using Windows and the shadow sample I immediately get disconnected after connecting and performing the TLS handshake. Wireshark shows the following output:

61	2.313533	192.168.15.167	54.154.234.121  TCP	      66        61059 → 8883 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1
69	2.358743	54.154.234.121	192.168.15.167	TCP	      66	8883 → 61059 [SYN, ACK] Seq=0 Ack=1 Win=26883 Len=0 MSS=1380 SACK_PERM=1 WS=256
70	2.358819	192.168.15.167	54.154.234.121	TCP	      54	61059 → 8883 [ACK] Seq=1 Ack=1 Win=66048 Len=0
72	2.373734	192.168.15.167	54.154.234.121	TLSv1.2	      257   	Client Hello
75	2.418502	54.154.234.121	192.168.15.167	TCP	      60    	8883 → 61059 [ACK] Seq=1 Ack=204 Win=28160 Len=0
76	2.420811	54.154.234.121	192.168.15.167	TCP	      1434	[TCP segment of a reassembled PDU]
77	2.420849	54.154.234.121	192.168.15.167	TLSv1.2	      1008      Server Hello, Certificate, Server Key Exchange, Certificate Request, Server Hello Done
78	2.420872	192.168.15.167	54.154.234.121	TCP	      54    	61059 → 8883 [ACK] Seq=204 Ack=2335 Win=66048 Len=0
79	2.427508	192.168.15.167	54.154.234.121	TLSv1.2	      1315 	Certificate, Client Key Exchange, Certificate Verify, Change Cipher Spec, Hello Request, Hello Request
83	2.474559	54.154.234.121	192.168.15.167	TLSv1.2	      105  	Change Cipher Spec, Hello Request, Hello Request
85	2.514520	192.168.15.167	54.154.234.121	TCP	      54        61059 → 8883 [FIN, ACK] Seq=1465 Ack=2386 Win=66048 Len=0
89	2.559828	54.154.234.121	192.168.15.167	TCP	      60        8883 → 61059 [FIN, ACK] Seq=2386 Ack=1466 Win=30720 Len=0
90	2.559864	192.168.15.167	54.154.234.121	TCP	      54        61059 → 8883 [ACK] Seq=1466 Ack=2387 Win=66048 Len=0

As you can see directly after line 83, a FIN ACK is sent closing the connection. Using OpenSSL and the following commandline openssl s_client -connect <endpoint>:8883 -CApath C:/AWS -cert <thingname>/cert.pem -key <thingname>/privkey.pem I instead get a working connection. I can also use for instance MQTT.fx to connect and communicate.

18012	638.716527	192.168.15.167	52.50.121.37	TCP	66	61408 → 8883 [SYN] Seq=0 Win=64240 Len=0 MSS=1460 WS=256 SACK_PERM=1
18015	638.761403	52.50.121.37	192.168.15.167	TCP	66	8883 → 61408 [SYN, ACK] Seq=0 Ack=1 Win=26883 Len=0 MSS=1380 SACK_PERM=1 WS=256
18016	638.761490	192.168.15.167	52.50.121.37	TCP	54	61408 → 8883 [ACK] Seq=1 Ack=1 Win=66048 Len=0
18017	638.761721	192.168.15.167	52.50.121.37	TLSv1.2	362	Client Hello
18018	638.806599	52.50.121.37	192.168.15.167	TCP	60	8883 → 61408 [ACK] Seq=1 Ack=309 Win=28160 Len=0
18019	638.811071	52.50.121.37	192.168.15.167	TCP	1434	[TCP segment of a reassembled PDU]
18020	638.811142	52.50.121.37	192.168.15.167	TCP	1434	[TCP segment of a reassembled PDU]
18021	638.811182	192.168.15.167	52.50.121.37	TCP	54	61408 → 8883 [ACK] Seq=309 Ack=2761 Win=66048 Len=0
18022	638.811432	52.50.121.37	192.168.15.167	TLSv1.2	408	Server Hello, Certificate, Server Key Exchange, Certificate Request, Server Hello Done
18023	638.815252	192.168.15.167	52.50.121.37	TLSv1.2	1325	Certificate, Client Key Exchange, Certificate Verify, Change Cipher Spec, Encrypted Handshake Message
18032	638.862213	52.50.121.37	192.168.15.167	TLSv1.2	105	Change Cipher Spec, Hello Request, Hello Request
18033	638.904352	192.168.15.167	52.50.121.37	TCP	54	61408 → 8883 [ACK] Seq=1580 Ack=3166 Win=65792 Len=0

MQTT Connection deadlock if any invalid details provided

Hi Team,

@JonathanHenson
@justinboswell

When we provide any invalid/incorrect connection details, we are observing an hang/deadlock in sdk (no connection callback receiving)

Case-I:
//invalid certificates
MqttCertificate cert1;
cert1.HostAddress = host_address; // used a valid IoT Core endpoint
cert1.port = port; // used 443
cert1.rootCA = "na";
cert1.clientCRT = "na";
cert1.clientKey = "na";

Result for Case-I:

  1. hang/deadlock in sdk and no callback receiving from sdk

Case-II:
//invalid endpoint
MqttCertificate cert1;
cert1.HostAddress = "172.16.2.109"; // this is not a valid endpoint
cert1.port = port; // used 443
cert1.rootCA = cert_root + root_ca;
cert1.clientCRT = cert_root + device_cert;
cert1.clientKey = cert_root + device_key;

Result for Case-II:

  1. Strangely here MQTT Connection was successful
  2. But when we used that connection to create subscriptions no callback received and hang/deadlock observing in sdk

Please test these from your side also and provide us fix.

Thank you.

Regards,
Ravichandhra Palla,
Hitachi Vantara.

OnInterrupt() and OnResume() getting called even though network connectivity has no issues

• The OnResume() either crashes, or even if it is called back , the connection is useless for any purposes.

• Added to this , seems this cycle of OnInterrupt() and OnResume() being called repeatedly is a brand new bug in SDK – even though we reverted our TCP socket options to default.
//Set to default
#define TCP_KEEP_ALIVE_INTERVAL_SEC 0 //5s
#define TCP_KEEP_ALIVE_TIMEOUT_SEC 0 //5s
#define TCP_KEEP_ALIVE_MAX_FAILED_PROBES 0 //2 - overall at end of 15s socket is deemed disconnected

Logger
Connection Interrupted with Error libaws-c-mqtt: AWS_ERROR_MQTT_TIMEOUT, Time limit between request and response has been exceeded.

As a matter of survival I added following changes to our code :

  1. For now we shutdown our complete stack whenever we get OnResume(). We restart our stack so as the connection is capable to publish in between the infinite cycles.
  2. If SDK crashes while calling OnResume() our service simply restarts.

Waiting on these fixes from @JonathanHenson in the meantime.

Setting "desired" state to null is not working

We trying to clear our desired state in the shadow.

std::string rejectJson;
rejectJson.append("{"desired":null}");
int rc1 = aws_sdk_gg->update_digital_twin(rejectJson);
EXPECT_EQ(SUCCESS, rc1);

The SDK converts null to {} and hence the AWS IoT broker/ GG broker does not clears the desired state.

UpdateShadowRequest request;
request.ThingName = thingName.c_str();
request.State = std::move(doc);

The line above converts null to {} as shown in logger below :

[15:23:41:759896165: +00:00] [---D---] [thread 14246] update_digital_twin:Shadow update request {"desired":null}

[15:23:41:760302783: +00:00] [---D---] [thread 14246] update_digital_twin:Shadow update request {
"state": {
}
}

An example for simple pub-sub communication?

Hello there.
I was told that the pub-sub functionality in this version of the AWS-IOT SDK is implemented.

From what I see, only device-shadow and jobs are given examples.

Where can I find an example of a simple pub-sub mechanism? will one be added eventually?

assert(0) missing from build

Here is how I achieved the failure:

git clone https://github.com/awslabs/aws-crt-cpp.git
clone https://github.com/awslabs/aws-iot-device-sdk-cpp-v2.git
mkdir aws-crt-cpp-build
cd aws-crt-cpp-build/
cmake -DCMAKE_INSTALL_PREFIX=~/testBuild/install -DCMAKE_PREFIX_PATH=~/testBuild/install ->DBUILD_SHARED_LIBS=ON -DBUILD_DEPS=ON ../aws-crt-cpp
make
make install 
cd ..
mkdir aws-iot-device-sdk-cpp-v2-build
cd aws-iot-device-sdk-cpp-v2-build/
cmake -DCMAKE_INSTALL_PREFIX=~/testBuild/install -DCMAKE_PREFIX_PATH=~/testBuild/install ->DBUILD_SHARED_LIBS=ON ../aws-iot-device-sdk-cpp-v2
make


Build is failing with missing assert...
[  1%] Building CXX object jobs/CMakeFiles/IotJobs->cpp.dir/source/GetPendingJobExecutionsResponse.cpp.o
[  3%] Building CXX object jobs/CMakeFiles/IotJobs-cpp.dir/source/JobStatus.cpp.o
/home/ubuntu/testbuild/aws-iot-device-sdk-cpp-v2/jobs/source/JobStatus.cpp: In function ‘const >char* Aws::Iotjobs::JobStatusMarshaller::ToString(Aws::Iotjobs::JobStatus)’:
/home/ubuntu/testbuild/aws-iot-device-sdk-cpp-v2/jobs/source/JobStatus.cpp:58:33: error: ‘assert’ >was not declared in this scope
                         assert(0);
                                 ^
/home/ubuntu/testbuild/aws-iot-device-sdk-cpp-v2/jobs/source/JobStatus.cpp: In function >‘Aws::Iotjobs::JobStatus Aws::Iotjobs::JobStatusMarshaller::FromString(const String&)’:
/home/ubuntu/testbuild/aws-iot-device-sdk-cpp-v2/jobs/source/JobStatus.cpp:107:25: error: ‘assert’ was >not declared in this scope
                 assert(0);
                         ^
jobs/CMakeFiles/IotJobs-cpp.dir/build.make:86: recipe for target 'jobs/CMakeFiles/IotJobs->cpp.dir/source/JobStatus.cpp.o' failed
make[2]: *** [jobs/CMakeFiles/IotJobs-cpp.dir/source/JobStatus.cpp.o] Error 1
CMakeFiles/Makefile2:85: recipe for target 'jobs/CMakeFiles/IotJobs-cpp.dir/all' failed
make[1]: *** [jobs/CMakeFiles/IotJobs-cpp.dir/all] Error 2
Makefile:127: recipe for target 'all' failed
make: *** [all] Error 2

compile error

Scanning dependencies of target Discovery-cpp
[ 80%] Building CXX object discovery/CMakeFiles/Discovery-cpp.dir/source/ConnectivityInfo.cpp.o
[ 82%] Building CXX object discovery/CMakeFiles/Discovery-cpp.dir/source/DiscoverResponse.cpp.o
[ 83%] Building CXX object discovery/CMakeFiles/Discovery-cpp.dir/source/DiscoveryClient.cpp.o
/Users/jakez/CLionProjects/aws-iot-device-sdk-cpp-v2/discovery/source/DiscoveryClient.cpp:154:54: error: no viable overloaded '='
requestOptions.onIncomingHeaders =
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1648:15: note: candidate function not viable: no known conversion from '(lambda at
/Users/jakez/CLionProjects/aws-iot-device-sdk-cpp-v2/discovery/source/DiscoveryClient.cpp:155:25)' to 'const std::__1::function<void (Aws::Crt::Http::HttpStream &, aws_http_header_block, const aws_http_header *, unsigned
long)>' for 1st argument
function& operator=(const function&);
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1649:15: note: candidate function not viable: no known conversion from '(lambda at
/Users/jakez/CLionProjects/aws-iot-device-sdk-cpp-v2/discovery/source/DiscoveryClient.cpp:155:25)' to 'std::__1::function<void (Aws::Crt::Http::HttpStream &, aws_http_header_block, const aws_http_header *, unsigned long)>' for
1st argument
function& operator=(function&&) _NOEXCEPT;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1650:15: note: candidate function not viable: no known conversion from '(lambda at
/Users/jakez/CLionProjects/aws-iot-device-sdk-cpp-v2/discovery/source/DiscoveryClient.cpp:155:25)' to 'std::nullptr_t' (aka 'nullptr_t') for 1st argument
function& operator=(nullptr_t) _NOEXCEPT;
^
/Library/Developer/CommandLineTools/usr/include/c++/v1/functional:1652:15: note: candidate template ignored: requirement '__callable<(lambda at
/Users/jakez/CLionProjects/aws-iot-device-sdk-cpp-v2/discovery/source/DiscoveryClient.cpp:155:25)>::value' was not satisfied [with _Fp = (lambda at
/Users/jakez/CLionProjects/aws-iot-device-sdk-cpp-v2/discovery/source/DiscoveryClient.cpp:155:25)]
function& operator=(_Fp&&);
^
1 error generated.
make[2]: *** [discovery/CMakeFiles/Discovery-cpp.dir/source/DiscoveryClient.cpp.o] Error 1
make[1]: *** [discovery/CMakeFiles/Discovery-cpp.dir/all] Error 2
make: *** [all] Error 2

Segmentation fault on callbacks

Based on our meeting with @JonathanHenson , we refactored our code to be conforming to the SDK, and it helped greatly.

We can now send in bugs with more confidence.
The fist segmentation fault we saw in our unit tests, is when the SDK tries to call the OnConnectionCompleted.
The fault occurs randomly , when we execute the same test again and again.

///*
// * This will execute when an mqtt connect has completed or failed.
// */
auto onConnectionCompleted = [this](Mqtt::MqttConnection &, int errorCode, Mqtt::ReturnCode returnCode, bool) {
{
...
}

Segmentation fault

I have a Greengrass core server, devices all one a local network using ethernet cables and router.
Wrote a simple unit test that publishes a small packet, and sleeps for 10s
Since TCP keep alive is 1s, and MQTT keep alive is 0 (Default), we see connection getting interrupted -> resumed , and the packets getting published.

If I take out the ethernet cable , in middle of the test, API gives segmentation fault.

Unit test code
*
Check connection and interruption does not effects the agent
Run the test, and remove the connectivity on device several times during the duraiton of test
*/
TEST_F(CAwsSdkInterfaceTest, test_publish_connection_resume_gg) {
aws_sdk_gg = new CAwsSdkInterface(mqtt_configuration);
int initialization_status = aws_sdk_gg->initialize_mqtt_client(cert, thing, mqtt_configuration);
std::cout << "initialize_mqtt_client: " << initialization_status << std::endl;
std::string ping_topic = topic_prefix + "ping/" + thing.thingName;
const int N = 10;
for (int iteration = 0; iteration < N; iteration++) {
std::cout << "#";
std::ostringstream ping_ostr;
ping_ostr << std::setprecision(10) << "{"ping": {"iteration": "" << iteration <<" of " << N << ""}}";
std::string s = ping_ostr.str();
int rc = aws_sdk_gg->publish(ping_topic.c_str(), (uint8_t *)s.c_str(), s.length());
EXPECT_EQ(SUCCESS, rc);
sleep(10); //sleep 10s
}
delete aws_sdk_gg;
std::cout << "test ends" << std::endl;
}

Segmentation fault if ethernet cable is pulled out in middle of test
#[21:06:04:191979123: +00:00] [---D---] [thread 15685] get_connection: success=false closed=false
[21:06:04:291231748: +00:00] [---D---] [thread 15686] Connection completed with return code 0
[21:06:04:295494498: +00:00] [---D---] [thread 15686] Connection state 2
[21:06:04:299868456: +00:00] [---D---] [thread 15685] get_connection: success=true closed=false
[21:06:04:301465831: +00:00] [---D---] [thread 15685] get_connection:end.
[21:06:04:302482623: +00:00] [---D---] [thread 15685] Publish waiting ...
[21:06:04:309094539: +00:00] [---D---] [thread 15686] Publish Operation on packetId 1 Succeeded
[21:06:04:313681998: +00:00] [---D---] [thread 15685] Publish finish waiting ...success=1 failures=0
[21:06:12:380085332: +00:00] [---W---] [thread 15686] mqtt connection interrupted
[21:06:12:564648790: +00:00] [---I---] [thread 15686] mqtt connection resumed
#[21:06:14:315468249: +00:00] [---D---] [thread 15685] Publish waiting ...
[21:06:14:323903374: +00:00] [---D---] [thread 15686] Publish Operation on packetId 1 Succeeded
[21:06:14:326554249: +00:00] [---D---] [thread 15685] Publish finish waiting ...success=2 failures=0
[21:06:20:622433624: +00:00] [---W---] [thread 15686] mqtt connection interrupted
Segmentation fault

Normal Run of same unit test without unplugging any device network
#[20:59:44:036314327: +00:00] [---D---] [thread 14244] get_connection: success=false closed=false
[20:59:44:157155536: +00:00] [---D---] [thread 14245] Connection completed with return code 0
[20:59:44:162096452: +00:00] [---D---] [thread 14245] Connection state 2
[20:59:44:167056202: +00:00] [---D---] [thread 14244] get_connection: success=true closed=false
[20:59:44:168901744: +00:00] [---D---] [thread 14244] get_connection:end.
[20:59:44:170123494: +00:00] [---D---] [thread 14244] Publish waiting ...
[20:59:44:173093786: +00:00] [---D---] [thread 14245] Publish Operation on packetId 1 Succeeded
[20:59:44:178381327: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=1 failures=0
[20:59:52:178706203: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[20:59:53:006151495: +00:00] [---I---] [thread 14245] mqtt connection resumed
#[20:59:54:180134453: +00:00] [---D---] [thread 14244] Publish waiting ...
[20:59:54:181192287: +00:00] [---D---] [thread 14245] Publish Operation on packetId 1 Succeeded
[20:59:54:186323120: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=2 failures=0
[21:00:01:020699288: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[21:00:01:380274663: +00:00] [---I---] [thread 14245] mqtt connection resumed
#[21:00:04:239229580: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:00:04:240064788: +00:00] [---D---] [thread 14245] Publish Operation on packetId 1 Succeeded
[21:00:04:249169746: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=3 failures=0
[21:00:09:391427705: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[21:00:09:581086539: +00:00] [---I---] [thread 14245] mqtt connection resumed
#[21:00:14:251553414: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:00:14:260382914: +00:00] [---D---] [thread 14245] Publish Operation on packetId 1 Succeeded
[21:00:14:263496331: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=4 failures=0
[21:00:22:592307373: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[21:00:23:318534832: +00:00] [---I---] [thread 14245] mqtt connection resumed
#[21:00:24:268669207: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:00:24:274161499: +00:00] [---D---] [thread 14245] Publish Operation on packetId 1 Succeeded
[21:00:24:281040290: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=5 failures=0
[21:00:31:325081750: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[21:00:31:415216166: +00:00] [---I---] [thread 14245] mqtt connection resumed
#[21:00:34:303658000: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:00:34:310594292: +00:00] [---D---] [thread 14245] Publish Operation on packetId 1 Succeeded
[21:00:34:313946250: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=6 failures=0
#[21:00:44:315651043: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:00:44:323804459: +00:00] [---D---] [thread 14245] Publish Operation on packetId 2 Succeeded
[21:00:44:326345418: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=7 failures=0
[21:00:49:491772752: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[21:00:49:827677960: +00:00] [---I---] [thread 14245] mqtt connection resumed
#[21:00:54:329464919: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:00:54:330348086: +00:00] [---D---] [thread 14245] Publish Operation on packetId 1 Succeeded
[21:00:54:334398419: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=8 failures=0
[21:00:57:836994336: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[21:00:58:083784711: +00:00] [---I---] [thread 14245] mqtt connection resumed
#[21:01:04:364733003: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:01:04:365557420: +00:00] [---D---] [thread 14245] Publish Operation on packetId 2 Succeeded
[21:01:04:374158003: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=9 failures=0
#[21:01:14:376021255: +00:00] [---D---] [thread 14244] Publish waiting ...
[21:01:14:384374588: +00:00] [---D---] [thread 14245] Publish Operation on packetId 2 Succeeded
[21:01:14:387420630: +00:00] [---D---] [thread 14244] Publish finish waiting ...success=10 failures=0
[21:01:21:157090172: +00:00] [---W---] [thread 14245] mqtt connection interrupted
[21:01:21:439670547: +00:00] [---I---] [thread 14245] mqtt connection resumed
[21:01:24:390056881: +00:00] [---D---] [thread 14244] cleanup sdk
[21:01:24:390474839: +00:00] [---D---] [thread 14244] disconnect_connection: wait completed closed=false
[21:01:24:391373173: +00:00] [---D---] [thread 14245] Connection disconnect state 3
[21:01:24:398193506: +00:00] [---D---] [thread 14244] disconnect_connection: wait completed closed=true
[21:01:24:399676214: +00:00] [---D---] [thread 14244] disconnect
[21:01:24:401680089: +00:00] [---D---] [thread 14244] bootstrap
[21:01:24:403999298: +00:00] [---D---] [thread 14244] defaultHostResolver
[21:01:24:406057256: +00:00] [---D---] [thread 14244] eventLoopGroup
[21:01:24:409891631: +00:00] [---D---] [thread 14244] tlsCtx
[21:01:24:411258256: +00:00] [---D---] [thread 14244] mqttClient
[21:01:24:411568548: +00:00] [---D---] [thread 14244] apiHandle
[21:01:24:419391839: +00:00] [---D---] [thread 14244] cleanup completed
test_iot_layer: /home/agupta/deviceagentcpp-bin/include/aws/crt/StlAllocator.h:57: void Aws::Crt::StlAllocator::deal locate(typename Aws::Crt::StlAllocator::Base::pointer, Aws::Crt::StlAllocator::size_type) [with T = char; typenam e Aws::Crt::StlAllocator::Base::pointer = char*; Aws::Crt::StlAllocator::size_type = unsigned int]: Assertion `g_ allocator' failed.

Segmentation Fault on disconnect network cable

This is running on a raspberry pi with raspbian.
mqttConnection->Ping(); is getting called every 10 seconds in a thread.

When I disconnect the network cable I get this segmentation fault after about 20-30 seconds

backtrace
#0 0x76ea1ff4 in s_hash_for (state=0x0, key=0x748fed36) at /home/pi/projects/aws-crt-cpp-build/deps/build/src/AwsCCommon/source/hash_table.c:68 #1 0x76ea274c in aws_hash_table_find (map=0x5d41c, key=0x748fed36, p_elem=0x748fed38) at /home/pi/projects/aws-crt-cpp-build/deps/build/src/AwsCCommon/source/hash_table.c:383 #2 0x76dc2a70 in mqtt_create_request (connection=0x5d378, send_request=0x76dc1260 , send_request_ud=0x5d378, on_complete=0x0, on_complete_ud=0x0) at /home/pi/projects/aws-crt-cpp-build/deps/build/src/AwsCMqtt/source/client_channel_handler.c:568 #3 0x76dc13f0 in aws_mqtt_client_connection_ping (connection=0x5d378) at /home/pi/projects/aws-crt-cpp-build/deps/build/src/AwsCMqtt/source/client.c:1288 #4 0x76eeca74 in Aws::Crt::Mqtt::MqttConnection::Ping (this=0x5bbb0) at /home/pi/projects/_crt_0/source/mqtt/MqttClient.cpp:578 #5 0x76f163ac in CAwsSdkInterface::ping (this=0x40368) at /home/pi/projects/iot_layer/src/CAwsSdkInterface.cpp:632 #6 0x76f86968 in connection_thread (ptrCPcsWorkFlow=0x40200) at /home/pi/projects/agent_workflow/sestra-workflow/src/CPcsWorkFlow.cpp:94 #7 0x76f8f5c8 in std::_Bind_simple::_M_invoke<0u>(std::_Index_tuple<0u>) ( this=0x5ef4c) at /usr/include/c++/6/functional:1391 #8 0x76f8f4bc in std::_Bind_simple::operator()() (this=0x5ef4c) at /usr/include/c++/6/functional:1380 #9 0x76f8f494 in std::thread::_State_impl >::_M_run() ( this=0x5ef48) at /usr/include/c++/6/thread:197 #10 0x76c5d9dc in ?? () from /usr/lib/arm-linux-gnueabihf/libstdc++.so.6 #11 0x769b2fc4 in start_thread (arg=0x748ff3d0) at pthread_create.c:458

Real-Time publish support

Hi,

Can we publish to multiple topics in real-time using this sdk?

means publish to different topics without any delay.

Can we do shadow operations and topics pub-sub in real-time , means without any delays?

Note: We want to use single mqtt client only. Using multiple clients(with different client ids) we can achieve this but we don't want to do this.

Thank you

Regards,
Ravichandhra Palla
Hitachi Vantara
[email protected]

Using this library alongside aws-cpp-sdk-iot

I'd like to be able to self-provision a device with IoT Core using the aws-cpp-sdk-iot library (with the help of the register-thing API). However, it appears that aws-cpp-sdk-iot uses different AWS library versions than aws-iot-device-sdk-cpp-v2.

I can build the two separate libraries without any trouble. When it comes to linking them in my own application, it looks like havoc ensues as there are duplicate libraries with different versions shared among the two.

Is there a recommended path forward for using these two IoT libraries from the same device without linker issues?

Can't compile on Ubuntu (libcrypto-config.cmake is missing)

Hi. I'm trying to build the v2 version with the commands provided in the README files:

git clone --branch v0.5.3 https://github.com/awslabs/aws-crt-cpp.git
git clone https://github.com/awslabs/aws-iot-device-sdk-cpp-v2.git

rm -rf aws-crt-cpp-build
mkdir aws-crt-cpp-build
cd aws-crt-cpp-build

cmake -DCMAKE_INSTALL_PREFIX="/usr" -DBUILD_SHARED_LIBS=ON -DBUILD_DEPS=ON ../aws-crt-cpp
cmake --build . --target install
cd ..

rm -rf aws-iot-device-sdk-cpp-v2-build
mkdir aws-iot-device-sdk-cpp-v2-build
cd aws-iot-device-sdk-cpp-v2-build

cmake -DCMAKE_INSTALL_PREFIX="/usr" -DBUILD_SHARED_LIBS=ON ../aws-iot-device-sdk-cpp-v2
cmake --build . --target install

It fails with the following error:

CMake Error at /usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package):
By not providing "FindLibCrypto.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"LibCrypto", but CMake did not find one.

Could not find a package configuration file provided by "LibCrypto" with
any of the following names:

LibCryptoConfig.cmake
libcrypto-config.cmake

Add the installation prefix of "LibCrypto" to CMAKE_PREFIX_PATH or set
"LibCrypto_DIR" to a directory containing one of the above files. If
"LibCrypto" provides a separate development package or SDK, be sure it has
been installed.
Call Stack (most recent call first):
/usr/lib/x86_64-linux-gnu/s2n/cmake/s2n-config.cmake:8 (find_dependency)
/usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
/usr/lib/x86_64-linux-gnu/aws-c-io/cmake/aws-c-io-config.cmake:4 (find_dependency)
/usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
/usr/lib/x86_64-linux-gnu/aws-c-http/cmake/aws-c-http-config.cmake:3 (find_dependency)
/usr/share/cmake-3.10/Modules/CMakeFindDependencyMacro.cmake:48 (find_package)
/usr/lib/aws-crt-cpp/cmake/aws-crt-cpp-config.cmake:3 (find_dependency)
CMakeLists.txt:93 (find_package)

-- Configuring incomplete, errors occurred!
See also "/home/rob/src/aws-v2/aws-iot-device-sdk-cpp-v2-build/CMakeFiles/CMakeOutput.log".
See also "/home/rob/src/aws-v2/aws-iot-device-sdk-cpp-v2-build/CMakeFiles/CMakeError.log".

My system is Ubuntu 18.04. libssl-dev (version 1.1.1-1ubuntu2.1~18.04.4) is installed. http://packages.ubuntu.com cannot find any package with LibCryptoConfig.cmake or libcrypto-config.cmake inside.

Am I missing something?

CMake build Error with VS2019 : error D8016: '/O2' and '/RTC1' command-line options are incompatible

CMake build with VS 2019 endes with error

cl : Command line error D8016: '/O2' and '/RTC1' command-line options are incompatible

`C:\Users\AvrahamShalev1\Documents\REUnderstand\aws-crt-cpp-build>cmake -DCMAKE_INSTALL_PREFIX="C:/Users/AvrahamShalev1/Documents/REUnderstand/AWS" -DCMAKE_PREFIX_PATH="C:/Users/AvrahamShalev1/Documents/REUnderstand/AWS" -DBUILD_SHARED_LIBS=ON -DBUILD_DEPS=ON ../aws-crt-cpp
-- Building for: Visual Studio 16 2019
-- The C compiler identification is MSVC 19.21.27702.2
-- The CXX compiler identification is MSVC 19.21.27702.2
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
install dir C:/Users/AvrahamShalev1/Documents/REUnderstand/AWS
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Checking Build System
CMake does not need to re-run because C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps/CMakeFiles/generate.stamp is up-to-date.
Creating directories for 'AwsCCommon'
Building Custom Rule C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp/aws-common-runtime/CMakeLists.txt
CMake does not need to re-run because C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps/CMakeFiles/generate.stamp is up-to-date.
Performing download step (git clone) for 'AwsCCommon'
Cloning into 'AwsCCommon'...
Note: checking out 'v0.3.6'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

git checkout -b <new-branch-name>

HEAD is now at cbe96ad Faster CBMC stubs for memset and memcpy (#300)
No update step for 'AwsCCommon'
No patch step for 'AwsCCommon'
Performing configure step for 'AwsCCommon'
-- The C compiler identification is MSVC 19.21.27702.2
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/VC/Tools/MSVC/14.21.27702/bin/Hostx64/x64/cl.exe -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Performing Test AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS
-- Performing Test AWS_HAVE_GCC_OVERFLOW_MATH_EXTENSIONS - Failed
-- Performing Test AWS_HAVE_MSVC_MULX
-- Performing Test AWS_HAVE_MSVC_MULX - Failed
-- Performing Test AWS_HAVE_GCC_INLINE_ASM
-- Performing Test AWS_HAVE_GCC_INLINE_ASM - Failed
-- Performing Test HAVE_M_AVX2_FLAG
-- Performing Test HAVE_M_AVX2_FLAG - Success
-- Performing Test HAVE_AVX2_INTRINSICS
-- Performing Test HAVE_AVX2_INTRINSICS - Success
-- Performing Test HAVE_MM256_EXTRACT_EPI64
-- Performing Test HAVE_MM256_EXTRACT_EPI64 - Success
-- Performing Test HAVE_MAY_I_USE
-- Performing Test HAVE_MAY_I_USE - Failed
-- Performing Test HAVE_BUILTIN_CPU_SUPPORTS
-- Performing Test HAVE_BUILTIN_CPU_SUPPORTS - Failed
-- Performing Test HAVE_MSVC_CPUIDEX
-- Performing Test HAVE_MSVC_CPUIDEX - Success
-- Looking for stdint.h
-- Looking for stdint.h - found
-- Looking for stdbool.h
-- Looking for stdbool.h - found
-- Performing Test HAS_WGNU
-- Performing Test HAS_WGNU - Failed
-- Performing Test HAVE_SYSCONF
-- Performing Test HAVE_SYSCONF - Failed
-- Building SIMD base64 decoder
-- Packaging is only supported on Linux
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps/build/src/AwsCCommon-build
Performing build step for 'AwsCCommon'
Microsoft (R) Build Engine version 16.1.76+g14b0a930a7 for .NET Framework
Copyright (C) Microsoft Corporation. All rights reserved.

Checking Build System
CMake does not need to re-run because C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps/build/src/AwsCCommon-build/CMakeFiles/generate.stamp is up-to-date.
CMake does not need to re-run because C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps/build/src/AwsCCommon-build/tests/CMakeFiles/generate.stamp is up-to-date.
Building Custom Rule C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps/build/src/AwsCCommon/CMakeLists.txt
CMake does not need to re-run because C:/Users/AvrahamShalev1/Documents/REUnderstand/aws-crt-cpp-build/deps/build/src/AwsCCommon-build/CMakeFiles/generate.stamp is up-to-date.

cl : Command line error D8016: '/O2' and '/RTC1' command-line options are incompatible [C:\Users\AvrahamShalev1\Documents\REUnderstand\aws-crt-cpp-build\deps\AwsCCommon.vcxproj]
C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets(429,5): error MSB6006: "CL.exe" exited with code 2. [C:\Users\AvrahamShalev1\Documents\REUnderstand\aws-crt-cpp-build\deps\build\src\AwsCCommon-build\aws-c-common.vcxproj] [C:\Users\AvrahamShalev1\Documents\REUnderstand\aws-crt-cpp-build\deps\AwsCCommon.vcxproj]
CMake Error at CMakeLists.txt:80 (message):
Failed to build aws crt libraries.

-- Configuring incomplete, errors occurred!

Abnormal MQTT Client Connection behavior with intermittent network connection

Hi,

We found these issues when network lost and resumed,

After network lost

  1. Disconnect message published to IoT topic after keep-alive expiration (ourcase: 30 x 1.5 = 45 sec)
  2. but the OnDisconnect/OnInterrupt handlers not triggering
  3. After disconnected message published also , Ping: mqttConnection->Ping() is working and
    connection-state: mqttConnection->GetConnectionState() is also 2(means connected)

After network resumed

  1. after getting network(with in keepalive) Onresume handler not triggering
  2. If network lost and get immediately then only the connection is alive otherwise disconnect message published to IoT topic

Thank you.

Regards,
Ravichandhra Palla
Hitachi Vantara
[email protected]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.