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

Check connection bug and onDataChanged #79

Closed Rokeder closed 8 years ago

Rokeder commented 8 years ago

Hello, everyone. I have the server, that send me some data. I can access to it by loginWithEmail method and get a data by subscribing. And cause it is server, connection to it can be different, but without "no accessing" or "shutdown", so it works pretty good and 24/7. My problem is that: I have button in my Application and when i click on it, occurs connection check like: if(Login.mMeteor.isConnected()&& Login.mMeteor.isLoggedIn()){ alertSingleChoiceItems(); }else if(!(Login.mMeteor.isConnected()) || !(Login.mMeteor.isLoggedIn())){ toast = Toast.makeText(getApplicationContext(),"Connection is lost", Toast.LENGTH_SHORT); toast.show(); toast.setGravity(Gravity.CENTER, 0, 0); } I have thread that reconnect the user to server again(with login,subscribing). But after some time, diffent and random periods, after i walked around the town, i open my application with internet and see that i am not connected, cause i didn't get any data from server when i calling this method on the page(fragment): Login.mMeteor.call("GetCourierProfile", new ResultListener(){/**just get a json file and show it*/}

So, i push the button and PERMORMS the first condition. Yes, application thinks, that is connected to the server. It is the first problem

Second problem is when i click this button and "i am connected" to the server, it must change some objects in json file on the server and i must get this changes in onDataChanged (by rules of your technology). In new version of your library, when i click the button it gives me no information about changing. Yes, json file is changed on the server, but it doesn't get any changing in onDataChanged. This is the second problem.

I very hope, that you can help me with these issues.

ocram commented 8 years ago

Thank you very much for this detailed report!

So the two problems are that (a) your application doesn't notice when the connection to the server is lost and it thinks that it's still connected to the server and (b) while you can still change data on the server, the server does not notify you about the changed documents via the callbacks. Is this correct?

If so, this issue might be related to your previous issue https://github.com/delight-im/Android-DDP/issues/57 and the two issues https://github.com/delight-im/Android-DDP/issues/66 and https://github.com/delight-im/Android-DDP/issues/74.

Rokeder commented 8 years ago

Thanks for this report!

If this is indeed a bug, we should definitely fix this as soon as possible.

Can you try performing some action on the Meteor connection every few seconds? This should allow us to see if the problems occur due to inactivity.

long interval = 5000;
Timer timer = new Timer();
timer.scheduleAtFixedRate(new TimerTask() {

    @Override
    synchronized public void run() {
        mMeteor.call("someNonExistentMethodForExample");
    }

}}, interval, interval);

(2) I didn't understand. I just write the code above in my application and call your method every 5 second. Is it right? For what period it should be in my application? (second problem)

(1) About the first problem with connection. I didn't find any useful thing that can change my situation in #74 issue.

ocram commented 8 years ago

The TimerTask should be running only in development, not in production, of course.

But apart from that, it's up to you how long it should be running. If you usually lose connections after 20 minutes, I'd say you should keep that task around for more than 20 minutes. It's purpose is to see if the connection is not lost if data is sent constantly.

You didn't find any solution in the other issues, but they're still related, right?

Rokeder commented 8 years ago

Yes, there are the same problems

ocram commented 8 years ago

Then, at some time, the connection must be lost and you must be able to observe the operation in the TimerTask failing, right? Can you notice anything?

Are you changing WiFis or moving outside so that there could be mobile handoff?

Rokeder commented 8 years ago

I am sorry for honesty, but YES, i develop the application, that can be connect to the server in any situation with mobile internet, except when server is off or internet is gone. in any place with internet.

Are you changing WiFis or moving outside so that there could be mobile handoff

I have thread that works in background and reconnect the user always, if connection is lost. I wrote all the things you need to know. This situation it doesn't matter. Yes, i can go outside. Yes, application will reconnect user. Yes, my application will be unstable, until you guys will fix this two bugs. Sorry for that, but i asked this question two or three months ago, but you didn't try to fix it. You have a great library and you have done a lot of work, but until you will not fix bugs like this, all applications with Meteor technology will be unstable and not relevant. I guess, that technology like this must be failover and stable(without "you went outside and your application doesn't work" or something like that) and soon many developers will use it, cause they will not think about the library bugs and just develop a cool applications. Guys, i am sorry for honesty again, but i describe the real situation. In three months you even didn't try to fix this bug.

ocram commented 8 years ago

i asked this question two or three months ago, but you didn't try to fix it.

We tried, but have no idea why this might happen, unfortunately. Would love to fix this!

Anyway, it's an open-source project. If somebody knows how to fix is, they might contribute.

Guys, i am sorry for honesty again, but i describe the real situation. In three months you even didn't try to fix this bug.

Being honest as well: As long as you don't pay for this, you don't have any entitlement to priority support.

Rokeder commented 8 years ago

I didn't try to injure you. But questions like "moving outside" or "just create a timer". So I have feeling, that you just don't try to fix it. I'll pay any money, if you will fix it.

ocram commented 8 years ago

This can only be fixed if we know why it's happening. So we have to debug it.

You have not provided that much valuable debugging information so far ;)

Things you could provide:

  1. The URL for a public test site that you control, where the problem occurs for you, where we can see if it's happening on our devices as well.
  2. Provide information about the timeframes that are crucial: When is it happening? After 2 minutes, 5 minutes, 20 minutes? Can you define some duration where it's always reproducible?
  3. Some sample code that is reduced to the minimum working example. What is the shortest excerpt of code we need to reproduce this? We don't want hundreds of lines of business logic.
Rokeder commented 8 years ago
  1. I can't give URL cause our system on Russian language and too complex for easy understanding. You will not understand.
  2. I said that it occurs in random periods and because CONNECTION always can be low.
  3. It's for the second problem. ANDROID: Login.mMeteor.call("finishAppByCourier", new Object[]{docId});

METEOR:

`finishAppByCourier: function(appToFinish) { check(this.userId, String); check(appToFinish, String);

var userId = this.userId; 
Applications.update(appToFinish, 
    { $set: 
        { 
        factDeliverDateTime: new Date(), 
        status: 'finished', 
        updated: new Date() 
        } 
      }
); 
var app = Applications.findOne(appToFinish); 
if(Meteor.isServer){ 
   Meteor.call('addToHistory', app, userId, 'courierFinishApp'); 
    if(app.client) 
      Meteor.call('notifyClientDelivered', app.client, app._id); 
} 
return { 
  success: true 
}; 

} `

Second problem is when i click this button and "i am connected" to the server, it must change some objects in json file on the server and i must get this changes in onDataChanged (by rules of your technology). In new version of your library, when i click the button it gives me no information about changing. Yes, json file is changed on the server, but it doesn't get any changing in onDataChanged. This is the second problem.

It works in 1.0.1 version, but doesn't work in new versions.

ocram commented 8 years ago

Can you use a Meteor web app to connect to this server and call the finishAppByCourier method? Do you get the updated data then or not? It should have the same behavior as the Android app.

Moreover, the part inside if(app.client) will probably not run for the Android client, will it?

Since you talk about JSON files, does that mean that you don't modify data in the MongoDB database but in files on the file system?

Rokeder commented 8 years ago

finishAppByCourier doesn't work when CONNECTION is bad

It doesn't mean. NO, it won't

if connection is bad, it modifies data on the server(mongodb), but mobile application doesn't get changed objects from server.

Rokeder commented 8 years ago

There are the same problems right now. What should i do?