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

Websocket Disconnected Issue #83

Open
yvdorofeev opened this issue Nov 25, 2016 · 3 comments
Open

Websocket Disconnected Issue #83

yvdorofeev opened this issue Nov 25, 2016 · 3 comments

Comments

@yvdorofeev
Copy link
Contributor

I found this issue while testing application on slow internet connections (well, it happens on all connections, it's just easier to reproduce when connection is slow enough). Here're steps to reproduce:

  1. Open an app that establishes connection to meteor. Since it's a first launch, I handle 'wait until meteor connected' in app, so that no code can make meteor requests until app is connected, logged in, blablabla.
  2. Minimize the app (without killing it) and wait few minutes - 5 minutes was enough in my case.
  3. Open an app and initiate Meteor request (method call in my case). Since there are no events that say when Meteor client connected/disconnected/errored out, there is no way to monitor that status in my code. And in this case, logs specify that there was an error and the state is actually disconnected.
  4. Callback is never called. My app is waiting for response indefinitely.

I see two issues with SwiftDDP related to this topic:

  1. Function client.sendMessage. It calls directly self.socket.send(m) and doesn't check if connection is opened. Inside SwiftSocket code only sends a message when connection is opened. Otherwise, message is not sent and callback is not called, obviously.
  2. Events. There's no way to track websocket events. The only events there are: User logged in, user logged out. I wish that client.events could be public and clients had an ability to hook to them. I saw that you are using DDPEvents in DDPClient, which prevents exposing it to the world. But those NSNotifications would be very helpful.

Yury

@yvdorofeev
Copy link
Contributor Author

I see, that you are only using 'onConnected' event. If it doesn't break the rest of the code, I could easily fork and add those Notification Center events to those callbacks. Let me know.

@siegesmund
Copy link
Owner

Yea, I see what you're saying. I think the problem is minimizing the app. SwiftDDP has never really handled that well.

I agree, it might be good to have notifications for other websocket events.

@yvdorofeev
Copy link
Contributor Author

You are right, but it's totally ok. If app knows what's going on with connection, it can control Meteor interaction.

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

No branches or pull requests

2 participants