Reconnection Policies for Python-Twisted SDK
Deprecated
NOTICE: Based on current web trends and our own usage data, PubNub's Python Twisted SDK is deprecated as of May 1, 2019. Deprecation means we will no longer be updating the Python Twisted SDK but will continue to support users currently using it. Please feel free to use our other Python SDK offerings as they will continue to be supported and maintained. If you would like to use the Python Twisted SDK specifically, we would love to work with you on keeping this project alive!
In networked applications, maintaining a stable connection is critical. The PubNub Python‑Twisted Software Development Kit (SDK) provides reconnection policies to help applications recover from temporary network disruptions.
Default behavior
Default behavior: If you do not set a reconnection policy, PNReconnectionPolicy.NONE
is used.
Types of reconnection policies
Choose the policy that best matches your environment and tolerance for retry delays during a network or internet issue.
-
PNReconnectionPolicy.NONE
(default): The SDK does not attempt automatic reconnection when there is a network or internet issue.- Use when: You need full control over retry logic or want to fail fast in short‑lived scripts and serverless functions.
-
PNReconnectionPolicy.LINEAR
: The SDK attempts to reconnect every 3 seconds until connectivity is restored.- Use when: You prefer consistent retry intervals in stable networks where brief outages are expected.
-
PNReconnectionPolicy.EXPONENTIAL
: The SDK uses the Exponential Backoff algorithm to reconnect when there is a network or internet issue. The SDK usesMINEXPONENTIALBACKOFF
= 1 second andMAXEXPONENTIALBACKOFF
= 32 seconds. See: https://en.wikipedia.org/wiki/Exponential_backoff for more details.- Use when: You want to reduce load on unstable networks or downstream services by spacing out retries.