pusher-lite icon indicating copy to clipboard operation
pusher-lite copied to clipboard

PusherClient#resetActivityCheck not actually disconnecting

Open paulstraw opened this issue 10 years ago • 1 comments

Hi there!

I'm using this library to communicate with Pusher from a Mac server. Unfortunately, when the server goes to sleep and is woken back up, the resetActivityCheck method calls its waitingTimeout. This wouldn't be a big deal, except the waitingTimeout doesn't actually seem to disconnect; it only unsubscribes from the connected channels. Here's the relevant code (from lib/pusher-node-client.coffee):

@waitingTimeout = setTimeout(
  () =>
    console.log "disconnecting because of inactivity at #{(new Date).toLocaleTimeString()}"
    _(@channels).each (channel) =>
        @unsubscribe channel.channel_name, channel.channel_data
    console.log "connetcing again at #{(new Date).toLocaleTimeString()}"
    if @connection.state isnt "open"
      @connect()
  30000
)

Is this intended behavior? If so, it would probably make sense to emit another event, so consumer code can know it should attempt to reconnect to any appropriate channels. If you'd like, I can make this change and submit a PR, or you can let me know if there's another solution you'd like implemented.

Thanks! -paul

paulstraw avatar Dec 08 '14 04:12 paulstraw

Hi,

I'm running into a similar issue. After a long connection to a Pusher feed, the channel will stop responding, but the state of the connection object remains "open" so the following connect statement never gets called:

if (_this.connection.state !== "open") {
    return _this.connect();
}

Also, nothing happens after this except the channels being unsubscribed. What paulstraw mentioned above would be great so I could reconnect to pusher and do other things as well.

Thank you!!

brettg2 avatar Sep 07 '15 20:09 brettg2