Hello to everybody,
I have a problem regarding the replication of a Phonegap/Cordova application, but before a little bit of background:
-
I have an external web application that is used by some users to save data in a couchbase server bucket in JSON format (bucket name: ‘oliclinomel’).
-
I have a sync gateway which it is shadowing the previous bucket. The purpose is to have the data of the shadowed bucket available for the people who install the mobile application in order to use it offline. The mobile users will just consume the data, they won’t create new documents in the sync_gateway, the data just goes in one direction. This is the configuration:
{
“interface”: “:5984”,
“adminInterface”: “:5985”,
“log”: [ “CRUD”, “CRUD+”, “HTTP”, “HTTP+”, “Access”, “Cache”, “Shadow”, “Shadow+”, “Changes”, “Changes+”, “SG” ],
“databases”: {
“oliclinomel_sync”: {
“server”: “http://localhost:8091”,
“bucket”: “oliclinomel_sync”,
“sync”: “function(doc) {channel(doc.channels);}”,
“users”: {
“GUEST”: {“disabled”: false, “admin_channels”: [""], “all_channels”: [""] },
“oliclinomel”: {
“disabled”: false,
“admin_channels”: [""],
“password”: “password”,
“admin_roles”: [],
“roles”: [],
“all_channels”: [""]
}
},
“shadow”: {
“server”: “http://localhost:8091”,
“bucket”: “oliclinomel”
}
}
}
}
For the moment I am using guest access as all the information stored in the couchbase server buckets in public, maybe later I will route the information in several channels depending on the content of the JSON documents.
When I start the sync_gateway it seems that all the documents are properly synchronized (you can see it in the log). So far so good, so the next step is to create the local CBLite database which should be synchronized with the sync gateway, and here is where my problems start.
When my application is loaded I make post request in order to replicate the bucket from the gateway:
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);
});
As far as I know the previous request is a one shot replication, which is ok as I don’t need a frequent synchronization, and if you take a look to the attached logs (line 60), you can see that all the documents are identified and sent to the local DB, but the problem is that when I retrieve the _all_docs from the CBLite DB in the app I get the documents in the below screenshot (2 design docs created in the setup of the local database and just 2 of the retrieved documents from the replication)
And if I make a second the replication request, the missing documents in the DB are retrieved by the gateway (as you can see in the log file) but the documents are not saved into CBLite and the local document that it is create to track the replications never is updated:
_sync:local:01202cb351fa162c38927bbcbf7ee22354f91089
{
"_rev": “0-1”,
“lastSequence”: “4”
}
I have tried also with continuous replication instead of one shot but I have the same problem, do you have any clue why this is happening to me?
I use the Phonegap Couchbase Lite plugin and the problems I have them with Android (in both device and emulator), I haven’t tested it on iOS yet.
About versions, I am using Couchbase server 3.0.1, sync gateway 1.0.3 (I am about to install the 1.0.4 to see if it gets better) and 1.0.3 of the Phonegap plugin for CBLite.
And also sometimes I get this error when I start the gateway:
11:50:22.092581 WARNING: Error from Incr in _reserveSequences(1): MCResponse status=DELTA_BADVAL, opcode=INCREMENT, opaque=0, msg: Non-numeric server-side value for incr or decr -- db.(*sequenceAllocator)._reserveSequences() at sequence_allocator.go:59
11:50:22.093581 FATAL: Error opening database: Couldn't create user "GUEST": MCResponse status=DELTA_BADVAL, opcode=INCREMENT, opaque=0, msg: Non-numeric server-side value for incr or decr -- rest.RunServer() at config.go:415
But usually after the 2nd or third try it works, I don’t know if it is related.
Thanks and best regards.
Jaime