Sync gateway pulling issue


#1

i am working in pure java and using sync gateway to pull and push data to server.
using this code to perform this :
URL url = new URL(“http://127.0.0.1:4984/omnibazaar”);
// URL url = new URL(“http://110.93.219.89:8091/omnibazaar”);
Replication push = db.createPushReplication(url);
Replication pull = db.createPullReplication(url);
pull.setContinuous(true);
push.setContinuous(true);
com.couchbase.lite.auth.Authenticator auth = AuthenticatorFactory.createBasicAuthenticator(“OB”, “test”);
push.setAuthenticator(auth);
pull.setAuthenticator(auth);
push.start();
pull.start();

my java code shows the following output:
Sep 08, 2015 8:19:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.ReplicationInternal$4@4d506e73 checkSessionAtPath() response: {authentication_handlers=[default, cookie], ok=true, userCtx={channels={!=1, *=1}, name=OB}}
Sep 08, 2015 8:19:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.ReplicationInternal$4@4ee15284 checkSessionAtPath() response: {authentication_handlers=[default, cookie], ok=true, userCtx={channels={!=1, *=1}, name=OB}}
Sep 08, 2015 8:19:12 PM com.couchbase.lite.util.SystemLogger w
WARNING: Sync: com.couchbase.lite.replicator.PullerInternal@22bb1eab: starting ChangeTracker with since=8 mode=OneShot
Sep 08, 2015 8:19:12 PM com.couchbase.lite.util.SystemLogger w
WARNING: Sync: com.couchbase.lite.replicator.PullerInternal@22bb1eab: started ChangeTracker com.couchbase.lite.replicator.ChangeTracker@2b891cf8
Sep 08, 2015 8:19:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: PullerInternal stopGraceful.run() finished

but pulling is not working.
kindly help


#2

Hey @jamiltz could you advise here please ?


#3

From the logs the authentication with Sync Gateway seems to be working as expected.
Hard to tell from these logs why the puller isn’t working, especially if pushing works.
Does the user with name OB and password test exist? Is there a runtime exception causing the app to crash? Can you share your Sync Gateway config file?

Thanks!
James


#4

this is config.json

{
“interface”:":4984",
“adminInterface”:":4985",
“log”:[“REST”],
“databases”:{
“omnibazaar”:{
“server”:“http://127.0.0.1:8091”,
“bucket”:“omnibazaar”,
“users”: { “OB”: { “password”: “test” , “disabled”: false, “admin_channels”: ["*"] } }
}}}


#5

@zeeshan_niazi

As you are not defining a sync function, you must add a “channels” property to your documents, to map them to at least one channel in order for them to be replicated to the “OB” user via a pull replication.

Andy


#6

can you help me to define channels property, how can i define this property.
as i have defined :

“users”: { “OB”: { “password”: “test” , “disabled”: false, “admin_channels”: ["*"] } }


#7

@zeeshan_niazi

Here is the section from the developer portal

If you don’t supply a sync function, Sync Gateway uses the following default sync function:

function (doc) {
   channel(doc.channels);
}

In plain English: by default, a document will be assigned to the channels listed in its channels property (whose value must be a string or an array of strings.) More subtly, since there is no validation, any user can change any document. For this reason, the default sync function is really only useful for experimentation and development.

so you can use

"channels":"mychannel",

or

"channels":["mychan1","mychan2","mychanN"],

In both cases documents should appear in a pull sync on the client. The channel names are not significant in this case  as the OB user has "admin_channels" set to "*". 

In more complex scenarios you can give different users access to different channels and map documents to a subset of those channels, allowing you to partition the data between users.

Andy