-
Notifications
You must be signed in to change notification settings - Fork 26
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
Fix RTN7c: notify publish callbacks of broken connection. #228
Conversation
tcard
commented
Feb 17, 2016
|
||
- (void)sendMessage:(ARTProtocolMessage *)pm cb:(ARTStatusCallback)cb { | ||
__block BOOL gotFailure = false; | ||
__block ARTEventListener *listener = [self.realtime.connection on:^(ARTConnectionStateChange *stateChange) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And if the current connection state is FAILED?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What then? The spec says "If a connection enters the CLOSED or FAILED state [...] the client should consider the delivery of those messages as failed", and that's what's happening here. (Maybe this is being done at the wrong level, though, because RTN7 is about ACK and NACK...)
LGTM |
} | ||
expect(gotPublishedCallback).toEventually(beTrue(), timeout: testTimeout) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure this is quite right. It's not clear that the state being lost has triggered the failure as opposed to just a timeout. What we need to check is that as soon as the new connection is made, and the connection state is lost because the connection ID has changed, then immediately all messages should be treated as failed to be published.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done at 7debb07.
Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions. ablySpec/RealtimeClientConnection.swift, line 781 [r1] (raw file): Comments from the review on Reviewable.io |
@mattheworiordan PTAL |
LGTM |
__block ARTEventListener *listener = [self.realtime.connection on:^(ARTConnectionStateChange *stateChange) { | ||
if (!(stateChange.current == ARTRealtimeClosed || stateChange.current == ARTRealtimeFailed | ||
|| (stateChange.current == ARTRealtimeConnected && ![oldConnectionId isEqual:self.realtime.connection.id] /* connection state lost */))) { | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you need to remove the listener as well, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe not. Line 168 stops the listener.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made it a once
instead of an on
. Fixed at fb5ccdd.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had to revert this at 2ed75ea. The listener only has to be unsubscribed if there's a failure or the message is sent. The connection can change several times before the message callback arrives, e. g. when reconnecting.
RealtimeClientConnection and RealtimeClientChannel tests are passing now on my machine, let's see if the whole suite does... (I'm not running all of them in my machine because that basically blocks me from working for half an hour.)
Can we merge this after a green test? |
I guess, I'm still trying to get this to pass... |
This looks like it's ready to be merged no? |
Test suite isn't passing:
|
💚 |
Fix RTN7c: notify publish callbacks of broken connection.
With the excitement... I forgot to autosquash 😖 Shame on me. |