RubyReconnection Policies Tutorial for Ruby V4


These docs are for PubNub 4.0 for Ruby which is our latest and greatest! For the docs of the older versions of the SDK, please check PubNub 3.0 for Ruby.

If you have questions about the PubNub for Ruby SDK, please contact us at

Pubnub Ruby SDK uses two parameters in reconnection logic: :reconnect_interval (in seconds) and :reconnect_attempts. They are set when initializing Pubnub::Client instance, by default their values are: 10 and 10.

When connection is lost, server logs warning “Connection lost! Reason: reasons”, announces status to subscribers with type: Pubnub::Constants::TIMEOUT_ANNOUNCEMENT(:disconnect). Then waits :reconnect_interval and tries to connect. When reconnected client announces to subscribers status type: Pubnub::Constants::RECONNECTED_ANNOUNCEMENT (:reconnected).