Comments (9)
Interesting. I can only assume what is happening here is that you are trying to unsubscribe from a channel on app resume or in some situation before the connection has been established?
libPusher supports subscribing prior to connection but I never really thought about unsubscribing before connecting. It's not a massive change but I might have to look at this tomorrow when I'm back at my desk.
from libpusher.
Just goes to show that assertions are useful for debugging though!
from libpusher.
Haha for sure :)
Ya if it fails to connect and the user chooses something in my app, they will subscribe to a channel. If they nav back and choose another, it will unsubscribe from the first and subscribe from the second. Makes sense if they failed to connect.
from libpusher.
I have a hunch that trying to subscribe to a channel before connecting will result in the same error. The reason for this is, looking at the code that subscribes to a channel, it looks like I was relying on behaviour of the old socket backend (AsyncSocket) where trying to send data over the socket before it was connected would simply fail.
That meant I could blindly send the "subscribe" message over the socket and have it fail, and then simply loop through the channels and call "subscribe" again when the connection was established, causing them to subscribe if they hadn't subscribed already.
Because SocketRocket (correctly) asserts that sending data before connection is an exception, I think this will now crash.
Could you test this theory and try subscribing to a channel without connecting the Pusher client?
from libpusher.
I think the correct solution would be to tease out a better state machine for channels instead of having a boolean "subscribed" flag.
For instance:
Starts as: Unsubcribed
SUBSCRIBE:
transition to: Waiting For Subscribe
if (connected) {
// do subscribe
transition to: Subscribed
}
else {
// wait for connection
}
UNSUBSCRIBE
transition to: Waiting For Unsubscribe
if (connected) {
// do unsubscribe
transition to: Unsubscribed
}
else {
// wait for connection
}
Then, in PTPusher (the connection delegate), when a connection is established:
foreach (channel that is in Waiting For Subscribe state) {
[channel subscribe]
}
foreach (channel that is in Waiting For Unsubscribe state) {
[channel unsubscribe]
// remove channel
}
from libpusher.
It may be worth having an additional state for private/presence channels such as Waiting For Authorization. I'll have a think about this.
from libpusher.
As you can see from my above commit, the more complicated state machine solution simply wasn't necessary. If the connection closes for some reason, for all intents and purposes you are unsubscribed from each channel (there isn't any need to send an unsubscribe message as well). We do mark channels as unsubscribed when disconnected, so the fix was to simply do nothing if you try and call unsubscribe on an already unsubscribed channel.
from libpusher.
Perfect. Thanks!
from libpusher.
Hi @lukeredpath
I'm still seeing a similar bug with a nightly build of Jun 26 2012, see #67
I cannot manage to reproduce but it's happening to a lot of our users. Any idea?
from libpusher.
Related Issues (20)
- Xcode 8 and iOS 10 HOT 10
- 'PTEventListener.h' file not found HOT 2
- No auth data sent in subscription event HOT 4
- Crash with PTNSJSONParser objectFromJSONString HOT 2
- [push notifications] Error callbacks? HOT 3
- Undefined symbols for architecture x86_64: "_OBJC_CLASS_$_PTPusher" HOT 1
- [Critical] Version Preprocessor Macro Crashes Cocoapods HOT 1
- Push lib crashes HOT 3
- Retain cycle in PTURLRequestOperation HOT 2
- ReactiveCocoa => ReactiveObjC for swift3
- Undefined symbols for architecture arm64 HOT 2
- Dynamic Channels HOT 4
- New release? HOT 4
- No current subscription to channel myChannel, or subscription in progress HOT 7
- Unable to read your certificate: failed to parse PKCS1 private key HOT 12
- Xcode 9 - PTPusherErrorDomain error while subscribing to private channel HOT 2
- Getting this error. "Value of type 'PTPusherPrivateChannel' has no member 'bind'" HOT 2
- 'WebSocketClient' is ambiguous for type lookup in this context
- Private channel not receiving pusher events. HOT 9
- add objective c documentation for Beam integration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libpusher.