aws / aws-iot-device-sdk-js-v2

Next generation AWS IoT Client SDK for Node.js using the AWS Common Runtime
Apache License 2.0
217 stars 97 forks source link

TSL Failing on Connect #429

Closed ajohnston1219 closed 11 months ago

ajohnston1219 commented 11 months ago

Describe the bug

When trying to connect to MQTT, TLS fails with error code -9805. Here are the relevant logs:

[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [socket-handler] - id=0x7fe826806650: writing message of size 31
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [socket] - id=0x7fe824c05420 fd=30: processing write requests, called from aws_socket_write
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [socket] - id=0x7fe824c05420 fd=30: dequeued write request of size 31, remaining to write 31
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [socket] - id=0x7fe824c05420 fd=30: send written size 31
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [socket] - id=0x7fe824c05420 fd=30: remaining write request to write 0
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [socket] - id=0x7fe824c05420 fd=30: write request completed
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [event-loop] - id=0x600002887430: scheduling task 0x600003e92740 in-thread for timestamp 0
[DEBUG] [2023-10-10T20:55:53Z] [0000700007c67000] [task-scheduler] - id=0x600003e92740: Scheduling socket_written_task task for immediate execution
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [tls-handler] - id=0x7fe826806780: bytes read 0
[ERROR] [2023-10-10T20:55:53Z] [0000700007c67000] [tls-handler] - id=0x7fe826806780: error reported during SSLRead. OSStatus code -9805
[TRACE] [2023-10-10T20:55:53Z] [0000700007c67000] [tls-handler] - id=0x7fe826806780: connection shutting down gracefully.

Expected Behavior

Able to connect to MQTT

Current Behavior

TLS failing

Reproduction Steps

Create a config using iot.AwsIotMqttConnectionConfigBuilder.new_default_builder

Call await connection.connect()

Eventually fails with:

Failure {
  error: CrtError: libaws-c-mqtt: AWS_ERROR_MQTT_UNEXPECTED_HANGUP, The connection was closed unexpectedly.
      at MqttClientConnection._on_connect_callback (~/projects/rome/common/temp/node_modules/.pnpm/aws-crt@1.18.0/node_modules/aws-crt/lib/native/mqtt.ts:662:48) {
    error: 5134,
    error_code: 5134,
    error_name: 'AWS_ERROR_MQTT_UNEXPECTED_HANGUP'
  }
}
Error CrtError: Failed to connect: libaws-c-mqtt: AWS_ERROR_MQTT_UNEXPECTED_HANGUP, The connection was closed unexpectedly.
    at ~/projects/rome/common/temp/node_modules/.pnpm/aws-crt@1.18.0/node_modules/aws-crt/lib/native/mqtt.ts:625:36
    at processTicksAndRejections (node:internal/process/task_queues:78:11) {
  error: 'Failed to connect: libaws-c-mqtt: AWS_ERROR_MQTT_UNEXPECTED_HANGUP, The connection was closed unexpectedly.',
  error_code: undefined,
  error_name: undefined
}

Possible Solution

No response

Additional Information/Context

No response

SDK version used

v2 - main

Environment details (OS name and version, etc.)

OS: macOS 14.0 (23A344) / Node: v16.20.0

bretambrose commented 11 months ago

Was your application connecting prior to upgrading to MacOS 14, or is this your first run?

ajohnston1219 commented 11 months ago

This is my first run

ajohnston1219 commented 11 months ago

I have managed to resolve the issue. It was a configuration issue with IoT core. Sorry for the trouble.

github-actions[bot] commented 11 months ago

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see. If you need more assistance, please either tag a team member or open a new issue that references this one. If you wish to keep having a conversation with other community members under this issue feel free to do so.