-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No current subscription to channel myChannel, or subscription in progress #254
Comments
It looks like you're calling |
Nope, I'm not calling The message seems to imply that it could be a case where the subscription is still in progress? |
Do you have a project you can share that recreates this problem? Or can you create a sample project that does? If not, please could you share the code that you've got that relates to libPusher so I can try and see if I can spot anything that could be causing the issue you're encountering? Thanks! |
I haven't been able to repro this issue myself. Here's our code: import Foundation
import Pusher
import SwiftyJSON
import Async
import CocoaLumberjack
class PusherDelegate: NSObject, StoreListener, PTPusherDelegate {
static let pusherQueue = dispatch_queue_create("pusherQueue", DISPATCH_QUEUE_SERIAL)
var client: PTPusher!
var subscribedUserChannel: PTPusherChannel?
override init() {
super.init()
Async.customQueue(PusherDelegate.pusherQueue) {
self.client = PTPusher(key: "my-pusher-api-key", delegate: self, encrypted: true)
self.client.authorizationURL = NSURL(string: "https://my-authorization-url")
self.client.connect()
}
}
func refresh() {
Async.customQueue(PusherDelegate.pusherQueue) {
guard let user = store.user.user else {
if let subscribedUserChannel = self.subscribedUserChannel {
subscribedUserChannel.unsubscribe()
self.subscribedUserChannel = nil
}
return
}
if let subscribedUserChannel = self.subscribedUserChannel where subscribedUserChannel.name != PusherDelegate.userChannelName(user.id, includePrefix: true) {
subscribedUserChannel.unsubscribe()
self.subscribedUserChannel = nil
}
if self.subscribedUserChannel == nil {
self.subscribedUserChannel = self.client.subscribeToPrivateChannelNamed(PusherDelegate.userChannelName(user.id, includePrefix: false))
self.subscribedUserChannel?.bindToEventNamed("event", handleWithBlock: { pusherEvent in
let event = JSON(pusherEvent.data)
guard event.error == nil else {
LogNonFatal("Pusher event data couldn't be parsed to SwiftyJSON: \(event.error)")
return
}
let data = event["data"]
guard let type = event["type"].string where data.isExists() else {
LogNonFatal("No type for event: \(event)")
return
}
// Events are handled here
})
}
}
}
static func userChannelName(userID: String, includePrefix: Bool) -> String {
return // a channel name specific to this user id
}
func pusher(pusher: PTPusher!, connectionDidConnect connection: PTPusherConnection!) {
refresh()
}
func pusher(pusher: PTPusher!, willAuthorizeChannel channel: PTPusherChannel!, withAuthOperation operation: PTPusherChannelAuthorizationOperation!) {
guard let url = operation.mutableURLRequest.URL else {
LogNonFatal("No URL on request")
return
}
guard let urlComponents = NSURLComponents(URL: url, resolvingAgainstBaseURL: false) else {
LogNonFatal("Couldn't parse URL to components")
return
}
var queryItems: [NSURLQueryItem]!
if let existingQueryItems = urlComponents.queryItems {
queryItems = existingQueryItems
} else {
queryItems = [NSURLQueryItem]()
}
queryItems.append(NSURLQueryItem(name: "our_auth_query_param", value: ourAuthValue))
urlComponents.queryItems = queryItems
operation.mutableURLRequest.URL = urlComponents.URL
}
func pusher(pusher: PTPusher!, connection: PTPusherConnection!, didDisconnectWithError error: NSError!, willAttemptReconnect: Bool) {
DDLogWarn("Pusher didDisconnectWithError: \(error)")
}
func pusher(pusher: PTPusher!, connection: PTPusherConnection!, failedWithError error: NSError!) {
DDLogWarn("Pusher connection:failedWithError: \(error)")
}
func pusher(pusher: PTPusher!, didFailToSubscribeToChannel channel: PTPusherChannel!, withError error: NSError!) {
if error.isNetworkError() {
DDLogWarn("Pusher didFailToSubscribeToChannel: \(channel) withError: \(error)")
} else {
LogNonFatal("Pusher didFailToSubscribeToChannel: \(channel) withError: \(error)")
}
}
func pusher(pusher: PTPusher!, didReceiveErrorEvent errorEvent: PTPusherErrorEvent!) {
if (errorEvent.code == 4201) {
DDLogWarn("Pusher didReceiveErrorEvent with \"pong\" code: \(errorEvent)")
} else {
LogNonFatal("Pusher didReceiveErrorEvent: \(errorEvent)")
}
}
} |
@hamchapman did you have a chance to look at this? any ideas of what could be going wrong? |
Is there a way that In that case it could be that you end up calling |
I found out for the browser SDK that if you call But if you call |
i'm seeing the following error after the user logs out and I call
PTPusherChannel.unsubscribe()
:Am I doing something wrong? Can I safely ignore errors with code
-1
?edit: libPusher 1.6.2 on iOS 10.2.1
The text was updated successfully, but these errors were encountered: