Do you plan to add a connection timeout feature to the Channels pusher-js client library?

No. The main focus of this library is to create and maintain a connection and manage our core features such as reconnection, subscription management and private and presence channels.

However, we do understand that in some situations you might want to do this within your application. This can be achieved relatively simply by calling the Pusher.disconnect() method. For example:

var pusher = new Pusher("APP_KEY");
var timeoutId = null;
function startInactivityCheck() {
    timeoutId = window.setTimeout(function(){
    }, 5 * 60 * 1000); // called after 5 minutes

// called by something that detects user activity
function userActivityDetected(){
    if(timeoutId !== null) {

if(pusher.connection.state === 'disconnected') {
} startInactivityCheck(); };

How this disconnection is trasmitted to the user is up to you but you may consider prompting them to let them know that they will not receive any further real-time updates due to a long period of inactivity. If they wish to start receiving real-time updates again they should click a button or you could automatically connect if activity is detected, as is shown in the code above.

Was this article helpful?
0 out of 0 found this helpful
Haven't found what you were looking for?
Submit a ticket