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

Status Events for Java SDK

The PubNub Java Software Development Kit (SDK) reports status events that describe connection state and error conditions. This page explains each status category and when it appears.

Subscribe loop

These status events apply to the latest subscription loop architecture introduced and enabled by default in version 9.0.0.

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


The PNStatusCategory enum defines the following subscription-related values:

StatusDescription
PNConnectedCategoryThe connection has been established and is ready to receive real-time updates.
PNDisconnectedCategoryThe connection has been intentionally terminated.
PNUnexpectedDisconnectCategoryThe connection was unexpectedly lost, with details about the error. This status may also mean that the reconnection attempts were unsuccessful.
PNConnectionErrorFailed to establish the initial connection, with details about the error. This status may also mean that the reconnection attempts were unsuccessful.
PNSubscriptionChangedThe 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. It does not include channels and groups that have been just subscribed.

Previous status categories​

StatusDescriptionRemoved in version
PNReconnectedCategorySDK was able to reconnect to PubNub. Now handled internally without a specific status. For more information on reconnection, refer to Configuration.9.0.0
PNAcknowledgmentCategoryAn API call was successful. This status has additional details based on the type of the successful operation. Now handled with operation-specific success callbacks. For more information on the channels and channel groups you've subscribed to, refer to the PNSubscriptionChanged status.9.0.0
PNTimeoutCategoryUsed API didn't receive a response from the server in time. Now represented by PubNubException with code 100.9.0.0
PNRequestMessageCountExceededCategoryReceived more messages than specified by requestMessageCountThreshold. No direct equivalent; use operation-specific callbacks.9.0.0
PNReconnectionAttemptsExhaustedThe subscribe loop has been stopped due to maximum reconnection exhausted. Now represented as PNConnectionError with specific exception.9.0.0
PNMalformedResponseCategoryPubNub 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.
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 specific statuses for heartbeat operations:

StatusDescription
PNHeartbeatSuccessA background implicit Heartbeat request was successful.
PNHeartbeatFailedA background implicit Heartbeat request attempt failed.
Heartbeat notification control

You can control which heartbeat notifications you receive using the PNHeartbeatNotificationOptions enum:

  • NONE: Do not report heartbeat events
  • FAILURES: Receive only failed heartbeat events
  • ALL: Receive all heartbeat events

Error events​

The Java SDK uses PubNubException to provide detailed error information. Most errors are returned in the exception property of the PNStatus object.

Common error types​

Error CodeMessageDescription
100Timeout OccurredAn asynchronous operation timed out.
102Connect ExceptionPlease verify if the network is reachable.
103HTTP ErrorPlease check network connectivity.
121JSON ErrorError while processing API response.
125Internal ErrorAn internal SDK error occurred.
126Parsing ErrorError while parsing data.
131Invalid argumentsAt least one request parameter is invalid.
135Crypto ErrorError while encrypting/decrypting message. Please contact support with error details.
Error CodeMessageDescription
138Subscribe Key MissingULS configuration failed. Subscribe Key not configured.
139Publish Key MissingULS configuration failed. Publish Key not configured.
114Secret Key MissingULS configuration failed. Secret Key not configured.

Resource errors​

Error CodeMessageDescription
132Channel MissingA required channel parameter is missing.
136Group MissingA required channel group parameter is missing.
141Channel and Group MissingBoth channel and channel group parameters are missing.
142Message MissingA required message parameter is missing.
140State MissingA required state parameter is missing.
144Device ID MissingA required device ID parameter is missing.
143Push Type MissingA required push type parameter is missing.
145Timetoken MissingA required timetoken parameter is missing.

Was this page useful?

Last updated on