-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Program hangs with Aws::Iot::MqttClient:NewConnection() #556
Comments
I think the issue has to do with the scope of
to
the problem goes away. Still not sure why the created connection being in scope prevents the program from continuing. And this doesn't help me much for creating a class that allows creating the connection, disconnecting, and using the connection to be handled in separate methods. |
Looking into the issue, the program stalls on the destructor of You can initialize the ApiHandle in main function and remove it from the member function. Example: int main(int argc, char** argv)
{
// Init ApiHandle here, and remove it from `InitializeConnection `
Aws::Crt::ApiHandle apiHandle;
std::cout << "\nStarting: " << argv[0] << "\n";
DEBUG_PRINT
AwsIotMqttHandler::connectionParameters_t connectionParameters;
connectionParameters.certificateFilepath = "/root/gateway/aws_keys/certificate.pem.crt";
connectionParameters.privateKeyFilepath = "/root/gateway/aws_keys/private.pem.key";
connectionParameters.rootCertificateFilepath = "/root/gateway/aws_keys/AmazonRootCA1.pem";
connectionParameters.endpoint = "a1ivqb4fk63pz7-ats.iot.us-east-1.amazonaws.com";
AwsIotMqttHandler awsIotMqttHandler;
awsIotMqttHandler.InitializeConnection(connectionParameters);
DEBUG_PRINT
return 0;
}
|
Also, that is the reason why the issue was resolved by changing the
As now the |
Solved! Thank you, @xiazhvera! |
Describe the bug
It is likely that this is user error rather than a bug. If so, please educate me on what I am doing wrong here.
Here's my simplified code:
Expected Behavior
Print
and exit. This is what happens if I comment out the
m_connection = client.NewConnection(clientConfig);
line.Current Behavior
Prints
(no
/root/gateway/experiments/aws_mqtt_connection_hang.cpp:83
line) and and does not exit. Three threads are left running:aws_mqtt_connec
AwsEventLoop 1
AwsEventLoop 2
Reproduction Steps
main
function.g++-13
c++20
.Possible Solution
No response
Additional Information/Context
No response
aws-crt-cpp version used
AWS CRT C++ 0.24.3
Compiler and version used
g++-13 (Ubuntu 13.1.0-8ubuntu1~22.04) 13.1.0
Operating System and version
Ubuntu 22.04.2 LTS
The text was updated successfully, but these errors were encountered: