Status Events for JavaScript SDK

Subscription loop

These status events apply to both subscription architectures available in the SDK: the default subscription manager and the newer, recommended subscription architecture (introduced in version 7.5.0 and enabled with enableEventEngine: true).

The latest subscription loop architecture provides the same status events with a more robust internal implementation.

The PubNub JavaScript SDK emits statuses to notify you about the state of the SDK.

SDK connection lifecycle

For more general information on statuses and reconnection policies, refer to SDK Connection Lifecycle.


StatusDescriptionIntroduced in version
PNConnectedCategory
PubNub client subscribed with a new mix of channels and is ready to receive real-time updates. This is fired every time the channel or channel group mix changes and upon connecting to the real-time updates stream for the first time.
before 4.0.6
PNDisconnectedCategory
PubNub client intentionally disconnected from the real-time updates stream.
before 4.0.6
PNDisconnectedUnexpectedlyCategory
PubNub client unexpectedly disconnected from the real-time updates stream. This status may contain an error field that provides more information about the error.
8.9.0
PNConnectionErrorCategory
PubNub client wasn't able to connect to the real-time updates stream. Returned when the previously started subscribe loop failed, and the client disconnected from real-time data channels. It can happen because of permissions errors or because the network is down. This status may contain an error field that provides more information about the error.
before 4.0.6
PNSubscriptionChangedCategory
The mix of subscribed channels and channel groups has changed. This event returns two arrays: 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.
9.5.0
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

StatusDescription
PNNetworkIssuesCategory
PubNub client wasn't able to reach PubNub servers because the machine or device isn't connected to the internet due to a network issue or the client is behind a proxy. For the subscribe loop, this information is provided as a part of the error field for received PNConnectionErrorCategory or PNDisconnectedUnexpectedlyCategory statuses.
PNBadRequestCategory
PubNub client wasn't initialized with the publishKey, the channel or message or both are missing from the payload, or the request is otherwise malformed.
PNReconnectedCategory
PubNub client was able to reconnect to PubNub and is ready to receive real-time updates.
PNAccessDeniedCategory
PubNub client wasn't able to process a request because the authorization key doesn't have read permissions for the required resources (Access Manager permission failure) and the PubNub server responded with HTTP 403. For the subscribe loop, this information is provided as a part of the error field for received PNConnectionErrorCategory or PNDisconnectedUnexpectedlyCategory statuses.
PNTimeoutCategory
PubNub client failed to establish a connection to PubNub due to a timeout (server didn't respond within the specified time frame).
PNRequestMessageCountExceededCategory
PubNub client exceeded the configured requestMessageCountThreshold (in-memory cache messages). It may suggest that you should enable Message Persistence on the keyset.
PNUnknownCategory
PubNub client received a non-200 HTTP response code from the server (unidentified reasons). For the subscribe loop, this information is provided as a part of the error field for received PNConnectionErrorCategory or PNDisconnectedUnexpectedlyCategory statuses.
PNCancelledCategory
PubNub client cancelled the request.
PNValidationErrorCategory
PubNub client provided incomplete parameters for a particular endpoint.
PNAcknowledgmentCategory
PubNub client received a request acknowledgment status.
PNMalformedResponseCategory
PubNub client received an unexpected response from PubNub or an intermediate actor. For the subscribe loop, this information is provided as a part of the error field for received PNConnectionErrorCategory or PNDisconnectedUnexpectedlyCategory statuses.

Browser-specific statuses

You can configure the SDK to emit the following additional statuses when the network status changes in the browser environment.

StatusDescription
PNNetworkDownCategory
The internet connection isn't available, or PubNub servers aren't reachable.
PNNetworkUpCategory
The internet connection is available, and PubNub servers are reachable.
Last updated on