CancelledError typically occurs when a connection attempt is explicitly cancelled or aborted during initialization. This can happen if your application logic or an abort controller is triggering a cancellation before the connection completes.
TimeoutError usually means the initialization process is taking longer than the configured timeout period. This can be caused by network issues, server unreachability, or insufficient timeout settings.
To address these errors:
• Check if your code or any abort controller is cancelling the connection attempt prematurely.
• Review your cancellation logic to ensure it isn't being triggered unintentionally during initialization.
• Increase the timeout values for connection attempts, especially if you suspect network latency or instability.
• Implement retry logic with exponential backoff for timeout scenarios.
• Verify network connectivity and server reachability before initializing the connection.
Proper error handling should distinguish between cancellations and timeouts, applying retries only where appropriate. If you need help with specific code or configuration, please provide details about your initialization logic and environment.