Read Timeout occurring frequently when fetching documents from Cosmos using `CosmosClient`
See original GitHub issueHi,
I have azure functions where I am using azure cosmos python SDK to fetch documents using SQL API, Please find the following piece of code that we I am using:
client = CosmosClient(host, credential=masterKey,
retry_total=15,
retry_backoff_max=30,retry_connect=4,retry_status=4,retry_read=4)
database = client.get_database_client(databasename)
container = database.get_container_client(collection)
items = container.query_items(query=query,enable_cross_partition_query=True)
This is the error I am facing:
HTTPSConnectionPool(host='XXXXX.documents.azure.com', port=443): Read timed out. (read timeout=60.0)
Please note that this issue used to occur randomly in our Data factory pipelines, but sometimes frequency is increasing. What can we do here? Please suggest.
Version Information
Python 3.8
azure-appconfiguration==1.1.1
azure-batch==9.0.0
azure-cli==2.14.0
azure-cli-core==2.14.0
azure-cli-telemetry==1.0.6
azure-common==1.1.25
azure-core==1.8.2
azure-cosmos==4.2.0
azure-datalake-store==0.0.51
azure-functions==1.4.0
azure-functions-devops-build==0.0.22
azure-functions-durable==1.0.0b10
azure-graphrbac==0.60.0
azure-keyvault==1.1.0
azure-keyvault-administration==4.0.0b2
azure-loganalytics==0.1.0
azure-mgmt-advisor==2.0.1
azure-mgmt-apimanagement==0.2.0
azure-mgmt-appconfiguration==0.6.0
azure-mgmt-applicationinsights==0.1.1
azure-mgmt-authorization==0.61.0
azure-mgmt-batch==9.0.0
azure-mgmt-batchai==2.0.0
azure-mgmt-billing==0.2.0
azure-mgmt-botservice==0.2.0
azure-mgmt-cdn==5.0.0
azure-mgmt-cognitiveservices==6.3.0
azure-mgmt-compute==14.0.0
azure-mgmt-consumption==2.0.0
azure-mgmt-containerinstance==1.5.0
azure-mgmt-containerregistry==3.0.0rc15
azure-mgmt-containerservice==9.4.0
azure-mgmt-core==1.2.0
azure-mgmt-cosmosdb==1.0.0
azure-mgmt-datalake-analytics==0.2.1
azure-mgmt-datalake-nspkg==3.0.1
azure-mgmt-datalake-store==0.5.0
azure-mgmt-datamigration==0.1.0
azure-mgmt-deploymentmanager==0.2.0
azure-mgmt-devtestlabs==4.0.0
azure-mgmt-dns==2.1.0
azure-mgmt-eventgrid==3.0.0rc7
azure-mgmt-eventhub==4.1.0
azure-mgmt-hdinsight==1.7.0
azure-mgmt-imagebuilder==0.4.0
azure-mgmt-iotcentral==3.0.0
azure-mgmt-iothub==0.12.0
azure-mgmt-iothubprovisioningservices==0.2.0
azure-mgmt-keyvault==7.0.0b3
azure-mgmt-kusto==0.3.0
azure-mgmt-loganalytics==0.7.0
azure-mgmt-managedservices==1.0.0
azure-mgmt-managementgroups==0.2.0
azure-mgmt-maps==0.1.0
azure-mgmt-marketplaceordering==0.2.1
azure-mgmt-media==2.2.0
azure-mgmt-monitor==0.11.0
azure-mgmt-msi==0.2.0
azure-mgmt-netapp==0.12.0
azure-mgmt-network==12.0.0
azure-mgmt-nspkg==3.0.2
azure-mgmt-policyinsights==0.5.0
azure-mgmt-privatedns==0.1.0
azure-mgmt-rdbms==3.1.0rc1
azure-mgmt-recoveryservices==0.4.0
azure-mgmt-recoveryservicesbackup==0.6.0
azure-mgmt-redhatopenshift==0.1.0
azure-mgmt-redis==7.0.0rc2
azure-mgmt-relay==0.1.0
azure-mgmt-reservations==0.6.0
azure-mgmt-resource==10.2.0
azure-mgmt-search==2.1.0
azure-mgmt-security==0.4.1
azure-mgmt-servicebus==0.6.0
azure-mgmt-servicefabric==0.5.0
azure-mgmt-signalr==0.4.0
azure-mgmt-sql==0.21.0
azure-mgmt-sqlvirtualmachine==0.5.0
azure-mgmt-storage==11.2.0
azure-mgmt-synapse==0.3.0
azure-mgmt-trafficmanager==0.51.0
azure-mgmt-web==0.48.0
azure-multiapi-storage==0.5.2
azure-nspkg==3.0.2
azure-search-documents==11.0.0
azure-servicebus==0.50.3
azure-storage-blob==12.5.0
azure-storage-common==2.1.0
azure-storage-file-datalake==12.1.1
azure-synapse-accesscontrol==0.2.0
azure-synapse-artifacts==0.3.0
azure-synapse-spark==0.2.0
Issue Analytics
- State:
- Created 3 years ago
- Comments:13 (3 by maintainers)
Top Results From Across the Web
Troubleshoot Azure Cosmos DB HTTP 408 ... - Microsoft Learn
In this article. Customize the timeout on the Azure Cosmos DB .NET SDK; Troubleshooting steps; Next steps. APPLIES TO: NoSQL.
Read more >Azure Cosmos DB SQL API client library for Python - PyPI
Use the Azure Cosmos DB SQL API SDK for Python to manage databases and the JSON documents they contain in this NoSQL database...
Read more >CosmoDB Connection Timeout - node.js - Stack Overflow
Tried it with that parameter and still no luck when running it from the app service. It continues to work when running locally....
Read more >Learn Live - Process bulk data in Azure Cosmos DB SQL API
Full series information: https://aka.ms/learnlive-azure-cosmosdb-certMore info here: https://aka.ms/learnlive-azure-cosmosdb-cert-Ep8Follow ...
Read more >Azure Cosmos DB 4xx Status Codes - Blue Matador
Request Timeout means the request did not complete in time. This can happen when a stored procedure, trigger, or UDF within a query...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

Update on this… the problem was cosmos account itself. We created a new cosmos account (same config except turned off analytics link, provisioned throughput) and the timeout issues went away.
Hi, me too, I’m receiving the same error since a few days ago I’m already using the singleton pattern, and creating a new cosmos account is not an option
Does anyone know how to solve the problem?