Couchbase Lite to CouchDB Replication - No Data


#1

I’m currently using CouchbaseLite on and Android app and I just started using the replication feature to synce to a couchdb database(Which I’m new to).

Heres the problem I’ve followed all the steps outlinedhere

My Replication object sends me an idle status. But I have no data in the specific couchdb database I pointed it to. Could there be anything I’m missing?

URL url = new URL("http://192.168.1.100:5984/data/");
        push = database.createPushReplication(url);
        pull = database.createPullReplication(url);
        pull.setContinuous(true);
        push.setContinuous(true);
        BasicAuthenticator authenticator = new BasicAuthenticator("olabode", "couch");
        pull.setAuthenticator(authenticator);
        push.setAuthenticator(authenticator);

        pull.addChangeListener(this);
        push.addChangeListener(this);

        push.setFilter("addStoreNameFilter");
        pull.setFilter("pullCurrentStoreFilter");

        // Start
        push.start();
        pull.start();

Here are my filters

database.setFilter("addStoreNameFilter", new ReplicationFilter() {
    @Override
    public boolean filter(SavedRevision savedRevision, Map<String, Object> map) {
        map.put(Dao.STORE_ID, storeId);
        return true;
    }
});

database.setFilter("pullCurrentStoreFilter", new ReplicationFilter() {
    @Override
    public boolean filter(SavedRevision savedRevision, Map<String, Object> map) {
        String currentStoreId = (String) map.get(Dao.STORE_ID);
        if (currentStoreId == storeId)
            return true;

        return false;
    }
});

Any help please


Multiple clients couchbase lite to server replication
#2

The code looks good.
Does the olabode user exist in the couchdb?
See https://wiki.apache.org/couchdb/How_to_create_users_via_script to create a user via the REST api.

Could you provide a bit more information on the HTTP traffic? You can use tools like Charles, HTTPScoop…to inspect network requests.
If exceptions are thrown, logs from the android debugger would also help to identify the source of the issue.

You could also consider syncing to Sync Gateway if you need more features like user management/access control of documents. See http://developer.couchbase.com/mobile/get-started/what-is-sync-gateway/index.html for more info.

Thanks
James


#3

I’ve found the problem. But solving it now would be quite a bummer. The couchbase lite replication engine attempts to access http://my-url/databasename/_session instead of http://my-url/_session causing the session check to fail. don’t know why that is but looking through my couchdb log showed this. So when I remove the database name part of my session check is successful but as you can expect the sync will fail because the database name is not specified. So I’m at cross road. I really don’t want to go the route of pulling down the source code and making the necessary edits my self.


#4

So I found out that that had been fixed with an update to version 1.0.4 which is what i did. it now the session is now authenticated.


#5

Glad you got it to work.
Thanks for sharing your findings!

James