delight-im / Android-DDP

[UNMAINTAINED] Meteor's Distributed Data Protocol (DDP) for clients on Android
Apache License 2.0
274 stars 54 forks source link

Connection bug #57

Closed Rokeder closed 8 years ago

Rokeder commented 8 years ago

I have MeteorSingleton mMeteor = MeteorSingleton.createInstance(this,"ws:....") variable(cause if use just Meteor it become null after 1-2 hours). I use this (by static) variable from many activities, fragments, list fragments. I have cases when application checks if !mMeteor.isConnected and !mMeteor.isLoggedIn and reconnect it. But there is problem. After few hours or less, application JUST IGNORE THIS CASES AND THINKS THAT IS CONNECTED BUT I GET NO DATA FROM SERVER. AND IN THIS SITUATION I JUST CAN'T RECONNECT BY THREAD OR ANY METHODS. This serious bug really makes my developing difficult, cause i can't handle this situation, cause maybe it's your bug. If you can help me with this, it will be awesome.

ocram commented 8 years ago

Wow, never really tried keeping connections for such a long time, sorry :)

We definitely need to see some excerpts of your code in order to understand what is being "ignored" after a few hours.

Apart from that, more information on the use case is needed. Is the app always in the foreground? Is the display always on or is it switched off during that 1-2 hour period?

Anyway, you should definitely take a look at Android's Activity lifecycle and the process lifecycle.

Rokeder commented 8 years ago

About some parts of code: It's not possible to write these, cause it's a lof of code. I can say that i just do like this: Login.mMeteor.reconnect() and refer to mMeteor by class, cause it's static.

About foreground: app can be in foreground, background it doesn't matter. Result after some time - application can't reconnect. Also when internet connection with exclamation mark(!) (you know when internet connection exists, but not available), result is the same, it will not reconnect, cause it ignores if(mMeteor.isConnected and mMeteor.isLoggedIn) cases.

ocram commented 8 years ago

Can you try this again when both the app is in the foreground all the time and the display is always on (i.e. the screen is somehow prevented from going off)?

Why are you calling Login.mMeteor.reconnect at all? Did you receive an onDisconnect or onException in your callback previously?

Is there any chance you could change the code of this library sourself (in a private fork) and test the scenario again with your changes?

The change that could be necessary is removing the if (mConnected) condition in the openConnection method.

ocram commented 8 years ago

Closing due to inactivity, and because this issue is a duplicate of https://github.com/delight-im/Android-DDP/issues/79 and https://github.com/delight-im/Android-DDP/issues/74