Skip to content

Handle Network Errors

Download may stuck because of network errors:

Downloaded: icon-d2_germany_regular-lat-lon_model-level_2025031912_048_8_tke.grib2.bz2
Failed to download icon-d2_germany_regular-lat-lon_model-level_2025031912_010_24_tke.grib2.bz2: HTTPSConnectionPool(host='opendata.dwd.de', port=443): Read timed out. (read timeout=None)
Failed to download icon-d2_germany_regular-lat-lon_model-level_2025031912_005_8_tke.grib2.bz2: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

Possible solutions:

  1. Timeout Issue response = requests.get(link, stream=True, timeout=30)

  2. RemoteDisconnected Issue

from requests.adapters import HTTPAdapter
from urllib3.util.retry import Retry

# Set up retry strategy
retry_strategy = Retry(
    total=5,  # Number of retries
    backoff_factor=2,  # Wait time between retries: 1s, 2s, 4s, 8s...
    status_forcelist=[429, 500, 502, 503, 504],
)

# Create session and attach retry strategy
adapter = HTTPAdapter(max_retries=retry_strategy)
session = requests.Session()
session.mount("https://", adapter)

# Use session instead of direct requests.get()
response = session.get(link, stream=True, timeout=30)
response.raise_for_status()