How to get all documents from the remote gateway

In my app the user may have multiple devices. Currently when the user uses the app on device A the information is synchronized correctly via the sync gateway. What I'm have trouble with is when the user uses the app on device B for the first time if i do a pull replication no documents are imported (I'm assuming because it looks for changes of which there are none).

What is the correct way to get the documents on the remote server on a new device?

So after some sleuthing the issue was that on device A in the code I was doing a pull replication then a push replication (both continuous). I tested some stuff and I decided to comment out the push replication and then put that version of the app on device B. Couchbase lite android is using information from the replication to create the checkpoint on the remote which is subsequently used to get changes from the remote. So device B has a different calculated checkpoint than what was put on the remote server by device A; sync gateway returned 404 for the checkpoint and then when _changes was called empty result was returned with a last_seq:0

This seems like a bug (not sure if it's the couchbaselite side of things or the gateway).

Can you please file an issue on Github?
https://github.com/couchbase/couchbase-lite-android/issues

I was about to log it as a bug but I wanted to be sure that it is a bug. I put the same version of the code on both device A and device B but still no go on getting the data to be pulled from the remote on device B (the checkpoint is different because of a different UUID) The expected behavior for me would be that on device b it would pull down all the documents from the remote db. So is the bug that the checkpoint doesn't match? Or is it that the change feed doesn't give all the documents if "since" is 0?

I also tried looking at the changes feed via curl and that too comes up blank. I ran _all_docs using the same user and I get total_rows as 84 so I don't think it's a permissions thing

The checkpoint ID should be different for the two devices. Every client/server pair uses a unique checkpoint ID, even if the user ID is the same.

That's strange that _changes is empty but _all_docs is not. Please file an issue and include a transcript of the requests & responses to both of those API calls (e.g. using curl.) Thanks!

The ticket has been created https://github.com/couchbase/couchbase-lite-android/issues/326 . I also got the todo lite app running on both devices (I made it use the 1.0 version from the maven repo) and the same thing seems to happen which is I login on device A and put content in and then login on device B but I don't see the content I put in on device A

1 Answer

« Back to question.

Yes that should work.

Have you checked out the TodoLite example? If you login to device A and add documents, then login to device B those docs will be sync'd down to device B.

Can you take a look and compare what you are doing differently to try to isolate the issue?

https://github.com/couchbaselabs/ToDoLite-Android

I've done this and it doesn't seem to work. I should point out that To get it to work I used version 1.0 from the maven repository