AWS_IO_TLS_ERROR_WRITE_FAILURE when connecting to IoT Core with Cognito Authenticated User
Hi. The same endpoints work fine if I use certs, but when I switch the auth to Cognito Authenticated users, it can't connect. The user authenticates and gets back credentials (secret key, etc.). Any help would be appreciated. I have a feeling it is a permissions issue, but I have no idea.
Here's the snippet (logs below):
cognito_id_pool_endpoint = f"cognito-identity.{os.getenv('COGNITO_REGION')}.amazonaws.com"
l = [(os.getenv('COGNITO_USER_POOL_URL'), idtoken)] # USER POOL
provider = auth.AwsCredentialsProvider.new_cognito(
endpoint=cognito_id_pool_endpoint,
identity=identityId,
logins=l,
tls_ctx=io.ClientTlsContext(io.TlsContextOptions()))
mqtt_connection = mqtt_connection_builder.websockets_with_default_aws_signing(
endpoint=os.getenv('IOT_ENDPOINT'),
region=os.getenv('IOT_REGION'),
client_id=f'my-device:{uuid.uuid4()}',
on_connection_failure=on_connection_failure,
on_connection_interrupted=on_connection_interrupted,
on_connection_resumed=on_connection_resumed,
credentials_provider=provider)
connect_future = mqtt_connection.connect()
connect_future.result()
logging.info('Connected!')
Here are the relevant logs:
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [event-loop] - id=0x14e965150: scheduling
task 0x14e9986e0 in-thread for timestamp 0
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [task-scheduler] - id=0x14e9986e0:
Scheduling socket_written_task task for immediate execution
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [tls-handler] - id=0x14e99b9b0: bytes read 0
[ERROR] [2024-01-12T00:59:46Z] [000000016b9ff000] [tls-handler] - id=0x14e99b9b0: error
reported during SSLRead. OSStatus code -9805
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [tls-handler] - id=0x14e99b9b0: connection
shutting down gracefully.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [socket-handler] - id=0x14e99b560: out of
data to read on socket. Waiting on event-loop notification.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [socket] - id=0x14e998f00 fd=23: is writable
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [socket] - id=0x14e998f00 fd=23: processing
write requests, invoked by the event-loop
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [event-loop] - id=0x14e965150: running
scheduled tasks.
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [task-scheduler] - id=0x14e9986e0: Running
socket_written_task task with <Running> status
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: beginning
shutdown process
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: shutting down
slot 0x14e99a7c0 (the first one) in the read direction
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: shutting down
slot 0x14e99a7c0, with handler 0x14e99b560 in read direction with error code 0
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [socket-handler] - id=0x14e99b560: shutting
down read direction with error_code 0
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: handler
0x14e99b560 shutdown in read dir completed.
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Websocket
handler shutting down dir=READ error_code=0 immediate=0.
[INFO] [2024-01-12T00:59:46Z] [000000016b9ff000] [mqtt-client] - id=0x14e161c00: sending
disconnect message as part of graceful shutdown.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: acquired
message 0x14e98ce70 of capacity 3 from pool 0x14e987c30. Requested size was 3
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [mqtt-client] - id=0x14e161c00: Acquiring
memory from pool of required_length 3
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: sending write
message of size 2, from slot 0x12f0bf120 to slot 0x12dedc3c0 with handler 0x14e1a8a20.
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Enqueuing outgoing frame with opcode=2(binary) length=2 fin=T [TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Scheduling synced data task.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Outgoing CLOSE frame queued, handler will finish shutdown once it's sent. [TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: websocket_close_timeout task will be run at timestamp 5628888184394625 [TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: scheduling task with wrapper task id 0x14e1a8c18.
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [task-scheduler] - id=0x14e1a8c18: Scheduling websocket_close_timeout task for future execution at time 5628888184394625
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [task-scheduler] - id=0x14e1a8a78: Running websocket_move_synced_data_to_thread task with <Running> status
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Websocket
will send no more data, future attempts to send will get error 2066
(AWS_ERROR_HTTP_WEBSOCKET_CLOSE_FRAME_SENT).
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Sending
aws_io_message of size 14 in write direction.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: sending write
message of size 14, from slot 0x12dedc3c0 to slot 0x14e99d4e0 with handler 0x14e99d8a8.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: sending write
message of size 14, from slot 0x14e99d4e0 to slot 0x14e998b00 with handler 0x14e99b9b0.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [tls-handler] - id=0x14e99b9b0: bytes
written:
0
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [tls-handler] - id=0x14e99b9b0: SSLWrite
failed with OSStatus error code -9805.
[ERROR] [2024-01-12T00:59:46Z] [000000016b9ff000] [http-connection] - id=0x14e99d8a0:
Destroying write message without passing it along, error 1031 (AWS_IO_TLS_ERROR_WRITE_FAILURE)
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Completed
outgoing frame=0x12f0b3750 opcode=2(binary) payload-length=2 with error_code 1031
(AWS_IO_TLS_ERROR_WRITE_FAILURE).
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Completed
outgoing frame=0x12f0b45f0 opcode=8(close) payload-length=0 with error_code 1031
(AWS_IO_TLS_ERROR_WRITE_FAILURE).
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00:
aws_io_message did not finish writing to socket, error 1031 (AWS_IO_TLS_ERROR_WRITE_FAILURE).
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [websocket] - id=0x14e1a8a00: Finishing
websocket handler shutdown.
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [channel] - id=0x14e999540: handler
0x14e1a8a20 shutdown in write dir completed.
[TRACE] [2024-01-12T00:59:46Z] [000000016b9ff000] [http-connection] - id=0x14e99d8a0: Channel
shutting down in write direction with error code 0 (AWS_ERROR_SUCCESS).
[DEBUG] [2024-01-12T00:59:46Z] [000000016b9ff000] [http-stream] - id=0x14e99ecb0: Stream
completed with error code 2058 (AWS_ERROR_HTTP_CONNECTION_CLOSED).
- Newest
- Most votes
- Most comments
Relevant content
- Accepted Answerasked a month agolg...
- asked 5 months agolg...
- Accepted Answerasked 2 years agolg...
- Accepted Answerasked 4 months agolg...
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 9 months ago