Skip to content

Conversation

@ankitdas13
Copy link
Contributor

@ankitdas13 ankitdas13 commented Aug 22, 2025

Fix intermittent connection issue

  • In the latest changes, the SDK handles ConnectionError exceptions at the application layer, which ensures retries even when there’s no response from the server.

intermittent connection issue

Exception :   ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response')) 
  1. Enable/Disable:
    • Retry mechanism is disabled by default
    • Can be enabled with client.enable_retry(True)
  2. If enabled:
    a. Number of times to retry:
    Default: 5 retries (defined in DEFAULTS['max_retries'])
    Configurable via constructor parameter
    client = razorpay.Client(auth=("key_id", "key_secret"), max_retries=3)
    
    b. Time period between retries / logic for exponential backoff:
    Uses exponential backoff with jitter
    Default parameters:
    Initial delay: 1 second
    Max delay cap: 60 seconds
    Formula: Each retry doubles the previous delay (delay_seconds *= 2), with added random jitter.
    Jitter is calculated as: jitter_value = random.uniform(-self.jitter, self.jitter)
    Final delay is: delay_seconds * (1 + jitter_value), capped at max_delay
    c. Specific conditions to retry on:
    retries on:
    requests.exceptions.ConnectionError : Network connectivity issues
    requests.exceptions.Timeout : Request timeout errors
    does NOT retry on:
    requests.exceptions.RequestException : Other request exceptions (edited)

# PackageNotFoundError: importlib.metadata couldn't find the package
# DistributionNotFound: pkg_resources couldn't find the package
# NameError: in case the exception classes aren't defined due to import issues
pass
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ignore these changes, i already created seperate PR for this , which is approved.

Copy link
Contributor

@razorpay-sanjib razorpay-sanjib left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ankitdas13 ankitdas13 added Tested TestingNotRequired TestingNotRequired label for BVT and removed Tested labels Sep 17, 2025
@ankitdas13 ankitdas13 merged commit 5f2142b into master Sep 17, 2025
11 of 12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

TestingNotRequired TestingNotRequired label for BVT

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants