Status Events for JavaScript SDK

Subscribe loop

The SDK emits different statuses depending on the subscription architecture you select: the default subscription manager, or the newer, recommended subscription architecture (introduced in version 7.5.0 and enabled with enableEventEngine: true).

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.

Available statuses

Depending on whether enableEventEngine is true or false, the SDK emits different statuses.


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.

Browser-specific statuses

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

It doesn't matter if enableEventEngine is true or false, the SDK emits the same browser-specific statuses.

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