Status Events for C# SDK
Subscription loop
These status events apply to the subscription loop introduced in version 6.20.0 and enabled by default in version 7.0.0.
The PubNub C# SDK provides status events to notify you about the state of the SDK through the PNStatusCategory
enum and PNException
types.
Subscription-related statuses
Status | Description |
---|---|
PNConnectedCategory | The connection has been established and is ready to receive real-time updates. |
PNDisconnectedCategory | The connection has been intentionally terminated. |
PNUnexpectedDisconnectCategory | The connection was unexpectedly disconnected. |
PNConnectionErrorCategory | Failed to establish the initial connection, with details about the error. |
PNSubscriptionChangedCategory | The mix of subscribed channels and channel groups has changed. This event returns two lists: one with all subscribed channels and the second with all subscribed channel groups. |
Previous status categories
Status | Description | Deprecated in version | Removed in version |
---|---|---|---|
PNReconnectedCategory | SDK was able to reconnect to PubNub. Now handled internally without specific status. | 6.20.0 | Not removed |
PNAcknowledgmentCategory | Used for API operation success reporting. Now handled with operation-specific success callbacks. | 6.20.0 | Not removed |
PNTimeoutCategory | Used when an API operation didn't receive a response from the server in time. Now represented by specific exceptions. | 6.20.0 | Not removed |
PNRequestMessageCountExceededCategory | Received more messages than specified threshold. No direct equivalent; use operation-specific callbacks. | 6.20.0 | Not removed |
PNNetworkIssuesCategory | Indicated network connectivity problems. Now represented as more specific status categories. | 6.20.0 | Not removed |
PNMalformedResponseCategory | PubNub sent a malformed response. This may happen when you connect to a public WiFi that requires you to log in via your web browser first, there is a proxy somewhere returning an HTML access denied error, or if there was an intermittent server issue. This status category is not actively emitted. Malformed responses now trigger a PNUnexpectedDisconnectCategory status with appropriate error details. | 6.20.0 | Not removed |
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:
Status | Description |
---|---|
PNAccessDeniedCategory | Authorization failed, usually due to invalid keys or token. |
PNCancelledCategory | The operation was cancelled before completion. |
PNDecryptionErrorCategory | Message decryption failed, likely due to incorrect crypto key. |
PNTLSConnectionFailedCategory | Secure connection failed due to TLS/SSL issues. |
PNTLSUntrustedCertificateCategory | TLS certificate validation failed. |
PNBadRequestCategory | The SDK is missing some required parameters, like message , channel , subscribe key , publish key . |
PNNetworkIssuesCategory | The SDK is not able to reach PubNub servers because the machine or device doesn't have Internet connection or the SDK is behind a proxy. |
PNTimeoutCategory | Processing has failed because of request timeout. |
PNNetworkIssuesCategory | The SDK is not able to reach PubNub servers because the machine or device doesn't have Internet connection or the SDK is behind a proxy. |
PNUnknownCategory | The captured error is a minor client-side error or an unknown type at the time of SDK development. |
PNBadRequestCategory | The SDK is missing some required parameters, like subscribe key or publish key . |
PNTimeoutCategory | Processing has failed because of request timeout. |
PNReconnectedCategory | SDK was able to reconnect to PubNub. |
Error events
The C# SDK uses PNException
to provide detailed error information. Most errors are returned in the exception property of the PNStatus
object.
Common error types
Error Code | Description |
---|---|
None | No error occurred. |
NameResolutionFailure | DNS resolution failed. Please check network connectivity. |
PublishOperationTimeout | A publish operation timed out. |
ReceiveFailure | Failed to receive data from the server. |
ConnectFailure | Failed to connect to the server. Please verify network reachability. |
WebRequestCanceled | Request was cancelled before completion. |
NoInternet | No internet connection detected. |
UnsubscribedAfterMaxRetries | Unsubscribed after maximum retry attempts were exhausted. |
MessageTooLarge | Message exceeded size limits. |
Key-related errors
Error Code | Description |
---|---|
InvalidKey | The key provided is invalid. |
InvalidSubscribeKey | The subscribe key is invalid or missing. |
NoUuidSpecified | No UUID was specified. |
Resource errors
Error Code | Description |
---|---|
InvalidChannel | A required channel parameter is invalid or missing. |
NotSubscribed | Operation attempted on a channel to which you're not subscribed. |
DuplicateChannel | Attempted to subscribe to a channel you're already subscribed to. |
EmptyGroupSubscription | Cannot subscribe to an empty channel group. |
InvalidTimestamp | The timestamp provided is invalid. |