Skip to content
This repository has been archived by the owner on Apr 17, 2019. It is now read-only.

DDP Web Socket Reset Cycle in Meteor 0.8.1.1 #74

Closed
vincilbishop opened this issue May 7, 2014 · 9 comments
Closed

DDP Web Socket Reset Cycle in Meteor 0.8.1.1 #74

vincilbishop opened this issue May 7, 2014 · 9 comments
Assignees

Comments

@vincilbishop
Copy link

DESCRIPTION

  • After upgrading to Meteor v0.8.1.1 iOS clients using the ObjectiveDDP library can no longer connect to the meteor server.
  • Downgrading the Meteor v0.8.0.1 allows those clients to again connect successfully.

Was there a change in the websocket implementation in Meteor v0.8.1.1?

A corresponding Meteor issue has been created here: meteor/meteor#2125

PRE-REQUISITES

  1. XCode installed
  2. Cocoapods installed
  3. Meteorite installed

STEPS TO REPRODUCE

$ git clone https://github.com/premosystems/meteor-issue-2125
$ cd ./meteor-issue-2125/meteor-example-failing-0.8.1.1
$ mrt &
$ cd  ../ios-example
$ pod update
$ Open ios-example.xcworkspace

Run the iOS app in the simulator.

ACTUAL BEHAVIOR

meteor-example-failing-0.8.1.1

Observe that a "You are not connected" error is returned from the login call. The websocket then goes into a cycle of being ready and not ready.

2014-05-07 09:47:07.304 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:07.306 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].connected: 0
2014-05-07 09:47:07.306 ios-example[95592:60b] [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:07.306 ios-example[95592:60b] [MYMeteorClient sharedClient].connected: 0
2014-05-07 09:47:07.307 ios-example[95592:60b] response: (null)
2014-05-07 09:47:07.307 ios-example[95592:60b] error: Error Domain=boundsj.objectiveddp.transport Code=0 "You are not connected" UserInfo=0x8f2b9a0 {NSLocalizedDescription=You are not connected}
2014-05-07 09:47:07.307 ios-example[95592:60b] websocketReady: 0
2014-05-07 09:47:11.335 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:47:11.338 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:11.339 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].connected: 0
2014-05-07 09:47:16.347 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:47:16.349 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:16.349 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].connected: 0
2014-05-07 09:47:21.358 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:47:21.360 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:21.360 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].connected: 0
2014-05-07 09:47:26.366 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:47:26.368 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:26.369 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].connected: 0
2014-05-07 09:47:31.375 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:47:31.377 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:31.377 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].connected: 0
2014-05-07 09:47:36.383 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:47:36.386 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 0
2014-05-07 09:47:36.386 ios-example[95592:60b] RAC: [MYMeteorClient sharedClient].connected: 0

The websocketReady/NotReady cycle is caused by the SocketRocket delegate method below, called with a code of 1000 and a nil reason string. wasClean is true.

- (void)webSocket:(SRWebSocket *)webSocket didCloseWithCode:(NSInteger)code reason:(NSString *)reason wasClean:(BOOL)wasClean

ObjectiveDDP makes the websocket connection using the following command. Note the "pre1" protocol version. Is this the version that should be used with Meteor v0.8.1.1?

[self.ddp connectWithSession:nil version:@"pre1" support:nil];

EXPECTED BEHAVIOR

meteor-example-passing-0.8.0.1

To demonstrate expected behavior, execute the same steps to reproduce, except start meteorite from the meteor-example-passing-0.8.0.1 directory.

2014-05-07 09:44:51.491 ios-example[95415:60b] RAC: [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:44:51.492 ios-example[95415:60b] RAC: [MYMeteorClient sharedClient].connected: 1
2014-05-07 09:44:51.492 ios-example[95415:60b] [MYMeteorClient sharedClient].websocketReady: 1
2014-05-07 09:44:51.493 ios-example[95415:60b] [MYMeteorClient sharedClient].connected: 1
2014-05-07 09:44:51.497 ios-example[95415:60b] websocketReady: 1
2014-05-07 09:44:51.603 ios-example[95415:60b] response: {
    logon = success;
}
2014-05-07 09:44:51.603 ios-example[95415:60b] error: (null)
@boundsj
Copy link
Owner

boundsj commented May 7, 2014

Thank you. Looks like v0.8.1.1 requires "pre2" for version. MeteorClient should allow users to set the version string. Will add that soon.

@vincilbishop
Copy link
Author

Want me to implement that and send you a pull request?

@boundsj
Copy link
Owner

boundsj commented May 7, 2014

Are you comfortable updating the specs too? If not then no worries, I can take care of it by the end of the day today. In any case, many many thanks!!!

@boundsj boundsj self-assigned this May 7, 2014
@vincilbishop
Copy link
Author

No but I'd like to learn...if you are going to do it today, I'll wait. I will study them so in the future I can contribute. Thanks!!!

@boundsj
Copy link
Owner

boundsj commented May 7, 2014

Ok. It'll be easier in the future, too, since cedar will be a pod. Will follow up here / offline.

@boundsj boundsj closed this as completed in 4ea0fd7 May 7, 2014
@boundsj
Copy link
Owner

boundsj commented May 7, 2014

@premosystems please see commit 4ea0fd7 for details.

Most relevant file changes are MeteorClient.h and MeteorClientSpec.mm. Note that ddpVersion is now a required param when initing MeteorClient - use "pre1" or "pre2" depending on which meteor server you use. I also updated the Example app and it's meteor app/server to reflect all of this.

I will forward port this feature to the ongoing work in this branch for the next release. It's worth noting that on that branch cedar is linked to as a pod and so the development environment and test running is generally easier to set up. Getting started with Cedar is still somewhat involved though and requires reading the cedar docs.

@glasser
Copy link

glasser commented May 9, 2014

See my comment on meteor/meteor#2125 !

doctorpangloss added a commit to hiddenswitch/ObjectiveDDP that referenced this issue May 11, 2014
[#fixes boundsj#74] Add meteor version as required parameter
nevyn added a commit to lookback/ObjectiveDDP that referenced this issue May 28, 2014
Sending nil is nonconformant and should result in a disconnection, because
the client is then saying “I don’t support any protocol versions at all”,
according to meteor/meteor#2125 .

Sending “support: [‘pre1’]” is a more correct fix than sending “version: pre2”,
since ObjectiveDDP doesn’t actually support pre2 yet. This is a more correct fix
to boundsj#74 .
@nevyn
Copy link
Contributor

nevyn commented May 28, 2014

If we pretend to be "pre2" without actually conforming to pre2, that means the server expects us to implement heartbeats and randomSeed (https://github.com/meteor/meteor/blob/devel/History.md#ddp-and-mongodb) but the client just ignores those messages. That sounds like things will start breaking.

I've followed @glasser's recommendation in meteor/meteor#2125 to add a "support:['pre1']" field to the connection message in lookback@3af67b4 .

@glasser
Copy link

glasser commented May 28, 2014

You'll need to implement heartbeats for pre2 (and should eventually: after all, we're in pre-1.0 land so I don't expect that we will implement pre1 indefinitely) but randomSeed is an optional feature sent by clients, so there's nothing to implement if you don't want to make it available to your users.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants