Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions src/nwp500/mqtt_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,10 +569,14 @@ async def connect(self) -> bool:

try:
# Build WebSocket MQTT connection with AWS credentials
self._connection = mqtt_connection_builder.websockets_with_default_aws_signing(
# Run blocking operations in a thread to avoid blocking the event loop
# The AWS IoT SDK performs synchronous file I/O operations during connection setup
credentials_provider = await asyncio.to_thread(self._create_credentials_provider)
self._connection = await asyncio.to_thread(
mqtt_connection_builder.websockets_with_default_aws_signing,
endpoint=self.config.endpoint,
region=self.config.region,
credentials_provider=self._create_credentials_provider(),
credentials_provider=credentials_provider,
client_id=self.config.client_id,
clean_session=self.config.clean_session,
keep_alive_secs=self.config.keep_alive_secs,
Expand Down