I’m running into a connection issue with the CDS API. Below are the details of my test script:
import cdsapi
client = cdsapi.Client(
url="https://cds.climate.copernicus.eu/api",
key="api_key",
timeout=600,
quiet=False,
debug=True,
verify=True,
)
dataset = "reanalysis-era5-land"
request = {
"variable": ["snow_depth_water_equivalent"],
"year": "2024",
"month": "10",
"day": ["1"],
"time": [
"00:00",
],
"data_format": "grib",
"download_format": "zip",
"area": [55, -100, 41, -68],
}
client.retrieve(dataset, request, "test.zip")
When I run this, the program halts after printing the following debug message:
2024-10-28 15:58:36,072 DEBUG GET https://cds.climate.copernicus.eu/api/catalogue/v1/messages
Recovering from connection error [HTTPSConnectionPool(host='cds.climate.copernicus.eu', port=443): Max retries exceeded with url: /api/catalogue/v1/messages (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x0000014FC357C5F0>, 'Connection to cds.climate.copernicus.eu timed out. (connect timeout=600)'))], attempt 1 of 500
Retrying in 120 seconds
I then modified the key
parameter to use the format key="uuid:api_key"
. After this, the program logs the following messages before encountering the same timeout error:
2024-10-28 16:00:50,791 DEBUG CDSAPI {'url': 'https://cds.climate.copernicus.eu/api', 'key': 'uuid:api_key', 'quiet': False, 'verify': True, 'timeout': 600, 'progress': True, 'sleep_max': 120, 'retry_max': 500, 'full_stack': False, 'delete': True, 'metadata': None, 'forget': False}
2024-10-28 16:01:11,836 INFO Sending request to https://cds.climate.copernicus.eu/api/resources/reanalysis-era5-land
2024-10-28 16:01:11,836 DEBUG POST https://cds.climate.copernicus.eu/api/resources/reanalysis-era5-land {"variable": ["snow_depth_water_equivalent"], "year": "2024", "month": "10", "day": ["1"], "time": ["00:00"], "data_format": "grib", "download_format": "zip", "area": [55, -100, 41, -68]}
2024-10-28 16:01:32,904 WARNING Connection error: [HTTPSConnectionPool(host='cds.climate.copernicus.eu', port=443): Max retries exceeded with url: /api/resources/reanalysis-era5-land (Caused by ConnectTimeoutError(<urllib3.connection.HTTPSConnection object at 0x00000282E6872CF0>, 'Connection to cds.climate.copernicus.eu timed out. (connect timeout=600)'))]. Attempt 1 of 500.
2024-10-28 16:03:42,917 WARNING Retrying in 120 seconds
Strangely, I can manually download the data from the CDS website without any issues, so I’m unsure why the script keeps timing out. Has anyone encountered a similar issue or have any advice on potential solutions?