2015-06-19 190 views
1

我得到一个相当简单的聊天应用程序与存在组推送订阅/取消订阅问题。在给定的时间应该有两个订阅频道。在骨干路由之间导航时,用户在频道之间切换,因此没有硬重新载入页面。推送者订阅和取消订阅过程

Pusher似乎在大多数情况下都能正常工作,但我频道订阅的间歇性错误。

我写了两个连接通道方法,如果已经加入了前一个路由,就退订。我担心Pusher内部会出现一些异常情况,这些情况正在破坏。

为单通道我推相关的代码:

window.pusher = new Pusher('<%= Pusher.key %>', { 
    authEndpoint: 'api/pusher/auth' 
}); 

路线:

this.groupFeed = this._pusherSubscribeGroup(group_id); 
this.groupFeed.bind('new_conversation', function(data) { 
    var newConv = new App.Models.Conversation(data); 
    this.group.conversations().add(newConv); 
}.bind(this)); 

退订帮手:

_pusherSubscribeGroup: function (group_id) { 
    if (this._groupChannelName) { 
    window.pusher.unsubscribe(this._groupChannelName); 
    } 
    this._groupChannelName = 'presence-group-' + group_id; 
    return window.pusher.subscribe(this._groupChannelName); 
} 

控制台错误:

Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Existing subscription to channel presence-group-1"}}} 

回答

0

Pusher : Error : {"type":"WebSocketError","error":{"type":"PusherError","data":{"code":null,"message":"Existing subscription to channel presence-group-1"}}}

该消息告诉您 - 就推送服务而言 - 由socket_id标识的此特定客户已订阅了presence-group-1频道。从客户的角度来看,这个错误通常是不是你真正需要担心的。

但是,如果用户正在通过导航路线快速订阅/取消订阅,那么值得获取更多信息以便完全确定。从提供的代码和说明中,无法确定问题是否在Pusher服务或客户端应用程序中。

提供Pusher JavaScript library logging的输出将提供更多详细信息,以帮助确定原因。