In my Mac 10.9.2
I installed couch base server and it is running on http://127.0.0.1:8091
It has it's default buckets including beer-sample
I started sync server as
./sync_gateway -bucket="beer-sample"
that logs following in console
14:00:55.903306 ==== Couchbase Sync Gateway/0.94 ====
14:00:55.979850 Configured Go to use all 2 CPUs; setenv GOMAXPROCS to override this
14:00:55.979985 Configured MaxFileDescriptors (RLIMIT_NOFILE) to 5000
14:00:56.005329 Opening db /beer-sample as bucket "beer-sample", pool "default", server <walrus:>
14:00:56.019242 Opening Walrus database beer-sample on <walrus:>
14:00:56.057276 Using default sync function 'channel(doc.channels)' for database "beer-sample"
14:00:56.057549 Starting profile server on
14:00:56.057680 Starting admin server on 127.0.0.1:4985
14:00:56.090556 Starting server on :4984 ...
In android my replication code looks like
Replication pullReplication = database.createPullReplication("http://10.0.2.2:4984");
pullReplication.start();
Then i ran my android app in simulator and i logged error as in changeEventListener
if (!replication.isRunning()){
Log.d(TAG, "Replication is not running due to " + replication.getLastError().getMessage());
Log.d(TAG, "Replication is not running due to " + replication.getLastError().getCause());
Log.d(TAG, "Replication is not running due to " + replication.getLastError().getStackTrace());
Log.d(TAG, "Replication is not running due to " + replication.getLastError().toString());
}
that logged
04-04 14:04:18.402 1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication: Puller[http://10.0.2.2:4984] changed.
04-04 14:04:18.432 1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to HTTP/1.1 404 Not Found
04-04 14:04:18.454 1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to null
04-04 14:04:18.502 1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to [Ljava.lang.StackTraceElement;@414efc88
04-04 14:04:18.502 1622-1644/com.couchbase.replicationsample.replicationsample D/HelloWorld﹕ Replication is not running due to com.couchbase.lite.CouchbaseLiteException: HTTP/1.1 404 Not Found
Note: I am using 10.0.2.2 instead of 127.0.0.1 because i read in forum that's how simulator maps the host machine. But i also tried 127.0.0.1 earlier which also gives the same result.
At the same time i am seeing in sync gateway console log a new entry like
14:05:13.532393 HTTP: #006: GET /_changes?feed=normal&heartbeat=300000
I tried to repeat this query in a browser like
> http://127.0.0.1:4984/_changes?feed=normal&heartbeat=300000
which is showing
{"error":"not_found","reason":"unknown URL"}
What is the mistake i am doing here? I am new to couch base.
Managed to get past this error:
Found a reference project in https://github.com/couchbaselabs/GrocerySync-Android
Key changes made to my original steps/code are
Executed sync gateway as ./sync_gateway -bucket="beer-sample" -url=“http://localhost:8091/beer-sample" -verbose
added database in the Sync URL like "http://10.0.2.2:4984/beer-sample
" i.e., database.createPullReplication("http://10.0.2.2:4984/beer-sample");
Ran into authorization error. To let anonymous access (for the time being) enabled GUEST account by executing below command in terminal
curl -X PUT localhost:4985/beer-sample/_user/GUEST --data '{"disabled":false, "admin_channels":["public"]}'