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개 답변
1
수락된 답변

-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
전문가
Greg_B
답변함 2년 전
  • 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.

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠