Couchbase lite replication

I am using couchbase lite replication.
what I understand is this. I have created couchbase lite db on my local machine. it created some a data folder in my code folder and I belive it must contains some couchbase lite db files.
now I want to transfer/ replicate this couchbase lite db/ files to my couchbase server which is install on my local machine, I can access it through ip : 127.0.0.1:8091.
I use the following code to perform replication:
URL url = new URL(“http://localhost:8091/sync_gateway/”);
Replication push = db.createPushReplication(url);
Replication pull = db.createPullReplication(url);
pull.setContinuous(true);
push.setContinuous(true);
com.couchbase.lite.auth.Authenticator auth = AuthenticatorFactory.createBasicAuthenticator(“Administrator”, “123456”);
push.setAuthenticator(auth);
push.setAuthenticator(auth);
pull.setAuthenticator(auth);
push.start();
pull.start();

i mentioned the db name which i have created on couchbase server full node. and username and password also of cuchbase server`s full node.
but i am unable to perform my task. i receive following errors:
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/sync_gateway/_session. Reason: Object Not Found
Jun 03, 2015 5:58:57 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/_session. Reason: Object Not Found
Jun 03, 2015 5:58:57 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.ReplicationInternal$4@46c7c485: Session check failed
org.apache.http.client.HttpResponseException: Object Not Found
at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:222)
at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:104)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Jun 03, 2015 5:58:57 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.PusherInternal@4f634ad6: Progress: set error = org.apache.http.client.HttpResponseException: Object Not Found
Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/sync_gateway/_session. Reason: Object Not Found
Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/_session. Reason: Object Not Found
Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/sync_gateway/_session. Reason: Object Not Found
Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.ReplicationInternal$4@2afd506: Session check failed
org.apache.http.client.HttpResponseException: Object Not Found
at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:222)
at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:104)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.PullerInternal@2d2050ea: Progress: set error = org.apache.http.client.HttpResponseException: Object Not Found
Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/_session. Reason: Object Not Found
Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.ReplicationInternal$4@4115f8ed: Session check failed
org.apache.http.client.HttpResponseException: Object Not Found
at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:222)
at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:104)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Jun 03, 2015 6:03:12 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.PusherInternal@455d59c3: Progress: set error = org.apache.http.client.HttpResponseException: Object Not Found
Jun 03, 2015 6:03:13 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/sync_gateway/_session. Reason: Object Not Found
Jun 03, 2015 6:03:13 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/sync_gateway/_session. Reason: Object Not Found
Jun 03, 2015 6:03:13 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/_session. Reason: Object Not Found
Jun 03, 2015 6:03:13 PM com.couchbase.lite.util.SystemLogger e
SEVERE: RemoteRequest: Got error status: 404 for http://localhost:8091/_session. Reason: Object Not Found
Jun 03, 2015 6:03:13 PM com.couchbase.lite.util.SystemLogger e
SEVERE: Sync: com.couchbase.lite.replicator.ReplicationInternal$4@2991c9a6: Session check failed
org.apache.http.client.HttpResponseException: Object Not Found
at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:222)
at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:104)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(ScheduledThreadPoolExecutor.java:178)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:292)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:745)

Hey,
you need to install sync gateway to replicate from your couchbase lite database to your couchbase server.
Check out the following guides:

running the sync

i have installed sync gateway,created syn_gateway buscket in couchbase server full node. and then run
sync_gateway -url http://localhost:8091 command, this start the sync gateway.
but it does not replicate/ transfer data to cocuhbase server full node.
i am using windows 8.
i am new to couchbase server kindly help me.

your are trying to sync with the url http://localhost:8091/sync_gateway/ which is the couchbase server
sync gateway runs on port 4984 on default

but you can see in guide:
http://developer.couchbase.com/mobile/develop/guides/sync-gateway/getting-started-with-sync-gateway/starting-sync-gateway/index.html
its mentioned that we have to run like:
sync_gateway -url http://localhost:8091
as you said, what is under that i must run as:
sync_gateway -url http://localhost:4984
but its showing error:
21:16:50.975491 WARNING: Error setting MaxFileDescriptors to 5000: Unsupported o
n Windows – rest.setMaxFileDescriptors() at config.go:378
21:16:50.976491 Opening db /sync_gateway as bucket “sync_gateway”, pool “default
”, server http://localhost:4984
21:16:50.977494 Opening Couchbase database sync_gateway on <http://localhost:498
4>
21:16:51.986483 FATAL: Error opening database: 502 Unable to connect to server:
Get http://localhost:4984/pools: dial tcp 127.0.0.1:4984: ConnectEx tcp: No conn
ection could be made because the target machine actively refused it. – rest.Run
Server() at config.go:415

i am talking about the code you posted in the first post

this needs to point to port 4984

Hi zeeshan_niazi,
I agree it can be a bit tricky to get all the parts working for Sync Gateway the first time. It takes some time to understand and configure all the parts correctly.
But luckily we have some very good samples in the most popular languages here:
Please note this is Client code (not Sync Gateway).
https://github.com/couchbaselabs?utf8=✓&query=todolite

The client code here uses a default Sync Gateway host that will allow you to test and see Sync Gateway working.

My recommendation is to play around with the client code and then when you understand it a bit more try to point it to you own sync gateway endpoint. If the client stops working you need to look into Sync Gateway Configuration, this guide should be helpfull.

http://developer.couchbase.com/mobile/develop/guides/sync-gateway/

Hi martinesmann,
I am java developer and I am working in windows environment, the examples mentioned by your are in android and IOS, so I cant understand those examples.
is there any guide or example, which can guide me to sync couchbase lite and sync gateway in java.
or any help regarding replication in couchbase lite.
infact I want to transfer my local couchbase lite data to some remote server.
thanks

right now even I don’t know how to add user in couchbase sync gate way.
can you help me to add user from java code.
when we run : http://localhost:4984/sync_gateway/
it ask me for username and password. which username and password is valid here ?

Sorry for the delay in my response! I have found the JRuby sample

Please let me know if that’s any help

Hi zeeshan_niazi,
It is possible to use the REST API for user management etc. but please note that due to security reasons the API is only accessible from localhost (the sync gateway server it self)

http://developer.couchbase.com/mobile/develop/guides/sync-gateway/administering-sync-gateway/administering-the-rest-apis/index.html