var remote = {
url: 'http://' + GATEWAY_HOST + BUCKET
};
var pullInfo = {
create_target: true,
source: remote,
target: dbName,
continuous: false,
cancel: false
};
$log.debug('[COUCHBASE]: Pulling changes from ', pullInfo.source);
return $http.post(cbUrl + '_replicate', pullInfo).then(function (res) {
$log.debug('[COUCHBASE_HOST]: Replication successful with session id ', res.data.session_id);
return res.data;
}, function (res) {
$log.debug('[COUCHBASE_HOST]: Replication failed: ', res);
});
I have finally fixed my issue, after install in my emulator a program to see the logs of the device, I noticed that this error was appearing every time the replication was done:
03-31 10:39:32.112 E/CBLite (3968): Database: Invalid top-level key '_class' in document to be inserted
03-31 10:39:32.112 I/CBLite (3968): CBLManagerWorkExecutor CANCEL transaction (level 2)
03-31 10:39:32.112 W/Sync (3968): com.couchbase.lite.replicator.PullerInternal@5cbee10: failed to write {Document-t_c-in-en #1-054356dc8a11d1fec32cff12df3d1688}: status=400
03-31 10:39:32.112 E/Sync (3968): com.couchbase.lite.replicator.PullerInternal@5cbee10: Progress: set error = org.apache.http.client.HttpResponseException
So it seems that the documents that have that attributes aren't replicated to CBLite. This '_class' attribute is added by the spring-data-couchbase library when saving some documents to the shadowed bucket in Couchbase Server, so I had to avoid saving the documents with that library and use the methods in the CocuhbaseClient instead. I don't know if this behaviour is correct but I think that the replication shouldn't fail if an attribute like that is saved to the document.
I think I will file an issue in github
Best regards.