basic-connect gives AWS_ERROR_MQTT_UNEXPECTED_HANGUP & error-code 1049

0

I fail to run the sample basic-connect. i receive:

[ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connect completion triggered with error -1073741252
[ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connection error with code 1049
Connection failed with error libaws-c-mqtt: AWS_ERROR_MQTT_UNEXPECTED_HANGUP, The connection was closed unexpectedly.
Connection failed

When I run:

basic-connect.exe --client_id "ME" --endpoint "[...]-ats.iot.eu-west-1.amazonaws.com" --cert "[...]/Certificate.crt" --key "[...]/private.key" --verbosity "Info"

Full output:

[INFO] [2022-10-05T13:09:04Z] [00007020] [pki-utils] - static: loading certificate chain with 3 certificates.
Connecting...
[INFO] [2022-10-05T13:09:04Z] [00007020] [mqtt-client] - id=000001C5BE6AE5F0: using ping timeout of 3000000000 ns
[INFO] [2022-10-05T13:09:04Z] [00007020] [thread] - id=000001C5BE69BFD0: cpu affinity of cpu_id 0 was specified, attempting to honor the value.
[INFO] [2022-10-05T13:09:04Z] [00005bd8] [socket] - static: initializing WinSock
[INFO] [2022-10-05T13:09:04Z] [00005bd8] [socket] - static: loading WSAID_CONNECTEX function
[INFO] [2022-10-05T13:09:04Z] [00005bd8] [socket] - static: loading WSAID_ACCEPTEX function
[ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connect completion triggered with error -1073741252
[ERROR] [2022-10-05T13:09:04Z] [00005b28] [socket] - id=000001C5BE6C1E30 handle=0000000000000214: connection error with code 1049
[INFO] [2022-10-05T13:09:04Z] [00005b28] [dns] - id=000001C5BE66C600: recording failure for record 2a01:578:3::22f6:70e6 for [...].eu-west-1.amazonaws.com, moving to bad list
Connection failed with error libaws-c-mqtt: AWS_ERROR_MQTT_UNEXPECTED_HANGUP, The connection was closed unexpectedly.
[INFO] [2022-10-05T13:09:05Z] [00005b28] [mqtt-client] - id=000001C5BE6AE5F0: sending disconnect message as part of graceful shutdown.
Connection failed

[...]basic_connect\build\x64-Debug\basic-connect.exe (process 30292) exited with code -1.

Why is there an overflow ("-1073741252")? I identified 1049 to be "AWS_IO_SOCKET_NO_ROUTE_TO_HOST", what does that mean?
Why is the connection not successful?

I am using msbuild & win10.

1 Answer
1
Accepted Answer

-1073741252 is 0xC000023C which is STATUS_NETWORK_UNREACHABLE. Between that and AWS_IO_SOCKET_NO_ROUTE_TO_HOST, it seems you may have some local networking issue. Please also carefully check the IoT Core endpoint you're using is correct, especially the 14-character unique identifier you redacted.

Update: Please also check your IoT policy (as fleshed in the comment conversation below).

profile pictureAWS
EXPERT
Greg_B
answered 2 years ago
  • I am not so sure. It worked to ping [...]-ats.iot.eu-west-1.amazonaws.com. A colleague of mine managed to establish a mqtt connection on this very endpoint from the same network as mine.

  • What is different between your setup and your colleague's?

  • This GitHub issue maybe helps: https://github.com/aws/aws-iot-device-sdk-cpp-v2/issues/440 . The reporter doesn't mention the error codes you've got, only the hangup. In that case, it's a problem with the IoT policy. Please check the IoT policy attached to the certificate of your Thing. I would not expect you to get network unreachable because of a policy problem, but policy problems are a common cause of connection issues.

  • Yes, sry. I forgot to mention that. I think the main difference is the way we generate the certificate.

  • We use JITP and i just realized that the clientID should be the common-name of our certificate according to our policy. So now i manage to reach print("Connected!"). However, I still receive STATUS_NETWORK_UNREACHABLE & AWS_IO_SOCKET_NO_ROUTE_TO_HOST errors. Especially, everytime i try to subscribe. I can try to run basic connect with my cert on another machine.

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions