For AI agents: this page in Markdown: https://www.pubnub.com/docs/sdks/asyncio/status-events.md. Documentation index: https://www.pubnub.com/llms-full.txt.

Status Events for Python-Asyncio SDK

The PubNub Python-Asyncio Software Development Kit (SDK) provides status events that describe the connection state and error conditions. This page outlines the available status categories, what they mean, and the versions in which their behavior was introduced or changed.

Subscribe loop

These status events apply to the newer subscribe loop introduced in version 7.4.0 and enabled by default in version 8.0.0.

The PubNub Python SDK provides status events to notify you about the state of the SDK through the PNStatusCategory enum and PNStatus types.


StatusDescriptionIntroduced in version
PNConnectedCategoryThe connection has been established and is ready to receive real-time updates.Introduced in 4.0.0, behavior changed in 10.3.0
PNDisconnectedCategoryThe connection has been intentionally terminated.Introduced in 4.0.0, behavior changed in 10.3.0
PNUnexpectedDisconnectCategoryThe connection was unexpectedly lost. Emitted when the subscribe loop fails, the client disconnects from real-time data channels, or the reconnection retry limit is reached and the SDK stops attempting to reconnect.Introduced in 4.0.0, behavior changed in 10.3.0
PNConnectionErrorCategoryFailed to establish the initial connection, with details about the error. This event is also emitted during connection failures in reconnect scenarios.10.3.0
PNSubscriptionChangedCategoryThe mix of subscribed channels and channel groups has changed.10.3.0

Previous status categories​

StatusDescriptionIntroduced in versionBehavior changed in version
PNReconnectedCategorySDK was able to reconnect to PubNub. In the newer subscribe loop, reconnection is handled with more granular statuses.4.0.07.4.0, 10.3.0 (enhanced)
PNAcknowledgmentCategoryAn API call was successful. This status has additional details based on the type of the successful operation. Also used in various transitions in the newer subscribe loop.4.0.07.4.0, 10.3.0 (enhanced)
PNTimeoutCategoryProcessing has failed because of request time out.4.0.0No significant change
PNNetworkIssuesCategoryThe SDK isn't able to reach PubNub servers due to network connectivity issues.4.0.010.3.0 (partially replaced by PNConnectionErrorCategory)
PNCancelledCategoryEmitted when a subscribe operation is cancelled.4.0.0No significant change
SDK connection lifecycle

Intermediate states like connecting and reconnecting are now handled internally without emitting specific statuses. For more general information on statuses and reconnection policies, refer to SDK Connection Lifecycle.

Other statuses​

The SDK provides additional statuses for various operations:

StatusDescription
PNAccessDeniedCategoryThe SDK will announce this error when the Access Manager does not allow the operation. Indicates authorization failures, typically due to invalid keys or token.
PNBadRequestCategoryPubNub API server was unable to parse SDK request correctly or request is missing required parameters like subscribe key or publish key.
PNMalformedFilterExpressionCategoryEmitted when a filter expression is malformed.
PNMalformedResponseCategoryEmitted when the server response is malformed.
PNDecryptionErrorCategoryEmitted when a message decryption error occurs, usually due to incorrect crypto key. Added in 4.5.4.
PNTLSConnectionFailedCategoryEmitted when a TLS connection fails, indicating secure connection issues.
PNTLSUntrustedCertificateCategoryEmitted when a TLS certificate is untrusted.
PNInternalExceptionCategoryEmitted for internal exceptions.
PNUnknownCategoryReturned when the subscriber gets a non-200 HTTP response code from the server or for unknown error types.

Error handling​

The Python SDK uses PNStatus to provide detailed error information. When handling errors, you'll encounter various status categories like PNNetworkIssuesCategory for connectivity issues, PNTimeoutCategory for request timeouts, and PNConnectionErrorCategory for connection failures.

The status object contains properties to help identify and handle errors:

PropertyDescription
categoryThe PNStatusCategory value identifying the type of status event.
errorBoolean indicating if this status represents an error.
error_dataContains detailed error information when an error occurs.
affected_channelsList of channels affected by this status event.
affected_groupsList of channel groups affected by this status event.
status_codeHTTP status code if applicable.
operationThe operation type that triggered this status.
tls_enabledBoolean indicating if TLS was enabled for this operation.
uuidThe UUID associated with this operation.
auth_keyThe authentication key used for this operation.

Was this page useful?

Last updated on