Skip to content
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

Merged
merged 6 commits into from
Feb 24, 2016

Conversation

tcard
Copy link
Contributor

@tcard tcard commented Feb 17, 2016

Review on Reviewable


- (void)sendMessage:(ARTProtocolMessage *)pm cb:(ARTStatusCallback)cb {
__block BOOL gotFailure = false;
__block ARTEventListener *listener = [self.realtime.connection on:^(ARTConnectionStateChange *stateChange) {
Copy link
Contributor

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?

Copy link
Contributor Author

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...)

@ricardopereira
Copy link
Contributor

LGTM

}
expect(gotPublishedCallback).toEventually(beTrue(), timeout: testTimeout)
Copy link
Member

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done at 7debb07.

@tcard
Copy link
Contributor Author

tcard commented Feb 18, 2016

Review status: 0 of 5 files reviewed at latest revision, 2 unresolved discussions.


ablySpec/RealtimeClientConnection.swift, line 781 [r1] (raw file):
Done at 7debb07.


Comments from the review on Reviewable.io

@tcard
Copy link
Contributor Author

tcard commented Feb 19, 2016

@mattheworiordan PTAL

@mattheworiordan
Copy link
Member

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;
Copy link
Contributor

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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.)

@ricardopereira
Copy link
Contributor

Can we merge this after a green test?

@tcard
Copy link
Contributor Author

tcard commented Feb 24, 2016

I guess, I'm still trying to get this to pass...

This was referenced Feb 24, 2016
@mattheworiordan
Copy link
Member

This looks like it's ready to be merged no?

@ricardopereira
Copy link
Contributor

Test suite isn't passing:

[08:24:32]: ▸ ablySpec.RealtimeClientConnection
[08:24:32]: ▸ Connection__ACK_and_NACK__should_trigger_the_failure_callback_for_the_remaining_pending_messages_if__lost_connection_state, failed - expected to be true, got <false>
[08:24:32]: ▸ /Users/travis/build/ably/ably-ios/ablySpec/RealtimeClientConnection.swift:788
[08:24:32]: ▸ ```
[08:24:32]: ▸                         expect(client.connection.id).toNot(equal(oldConnectionId))
[08:24:32]: ▸                         expect(gotPublishedCallback).to(beTrue())
[08:24:32]: ▸                     }

@ricardopereira
Copy link
Contributor

💚

ricardopereira added a commit that referenced this pull request Feb 24, 2016
Fix RTN7c: notify publish callbacks of broken connection.
@ricardopereira ricardopereira merged commit 909c77f into master Feb 24, 2016
@ricardopereira ricardopereira deleted the fix-rtn7c branch February 24, 2016 16:41
@ricardopereira ricardopereira restored the fix-rtn7c branch February 24, 2016 17:07
@ricardopereira
Copy link
Contributor

With the excitement... I forgot to autosquash 😖 Shame on me.

@mattheworiordan mattheworiordan deleted the fix-rtn7c branch February 25, 2016 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants