Grocery Sync app

153 views
Skip to first unread message

James Norman

unread,
Apr 19, 2014, 8:29:45 PM4/19/14
to mobile-c...@googlegroups.com
Hey all, I've really been struggling with the grocery sync application and could use some advice.  We're looking to move our android application to couchbase and use the syncing.  I need to demo/prototype it to sell the technology.

I have the grovery sync app installed and running however I can't get it to sync between devices.

I installed couchbase server and sync gateway on ubuntu 12.  I added the guest user using:
curl -X PUT localhost:4985/sync_gateway/_user/GUEST --data '{"disabled":false, "admin_channels":["public"]}'

I set the SYNC_URL="http://<myserverip>:4984/sync_gateway"

And left everything else the same.

And started the application in my device and an emulator.  From both devices I can see activity on the server, reading:
00:20:42.455918 HTTP:  #533: GET /sync_gateway/_changes?feed=longpoll&limit=50&h
eartbeat=300000
00:20:44.463402 HTTP:  #534: POST /sync_gateway/_revs_diff
00:20:45.298603 HTTP:  #535: POST /sync_gateway/_bulk_docs
00:20:47.571836 HTTP:  #536: PUT /sync_gateway/_local/e8f6e0ce7e9466bf361ef54f62
f164e24f4118bc
00:20:55.533451 HTTP:  #537: POST /sync_gateway/_revs_diff
00:20:55.751152 HTTP:  #538: POST /sync_gateway/_bulk_docs
00:20:58.002003 HTTP:  #539: PUT /sync_gateway/_local/e8f6e0ce7e9466bf361ef54f62

etc.  

I can never get changes to sync between devices, or persist between a cache clearing.

Thanks so much for any help, I think couchbase is the technology we need to use but I'm having some troubles prototyping it to sell it to our organization.

Thanks again for the time and any advice.

-james

Jens Alfke

unread,
Apr 19, 2014, 9:25:25 PM4/19/14
to mobile-c...@googlegroups.com
On Apr 19, 2014, at 5:29 PM, James Norman <james....@gmail.com> wrote:

And started the application in my device and an emulator.  From both devices I can see activity on the server, reading:
00:20:42.455918 HTTP:  #533: GET /sync_gateway/_changes?feed=longpoll&limit=50&heartbeat=300000

This indicates that a pull replicator is running on a client and listening for changes. So far so good.

00:20:44.463402 HTTP:  #534: POST /sync_gateway/_revs_diff
00:20:45.298603 HTTP:  #535: POST /sync_gateway/_bulk_docs

And this indicates that a push replicator on a client is sending local changes to the server. Even better.

etc.  

What you should also be seeing in the gateway log are some GET requests with paths like “/sync_gateway/xxxx” where “xxxx” will probably be a UUID (long hex string). That will indicate that the puller is downloading new changes from the server. (You might also see POSTs to /sync_gateway/_bulk_get, but I don’t think the Android implementation uses _bulk_get yet.)
If you upload the full logs to gist or pastebin or whatever, I can take a look.

Unfortunately I can’t help much with the Android side, as I work on iOS. Traun or Andy will be of more use with that.

Oh also, what versions of the software are you running?

—Jens

James Norman

unread,
Apr 19, 2014, 9:50:05 PM4/19/14
to mobile-c...@googlegroups.com
Thanks so much for the quick response!  I installed the latest versions of couchbase and the sync gateway from the downloads page today, and the beta 2 of the CouchbaseLite for android

And the "beta2" of the Grocery Sync application here:

I'll try with the master branch of the Grocery app now.  

Are there any other "current" demo applications or guides that may help with this.  I'm positive couchbase and lite is the technology we need to use.

Only other thing to note is I don't build the apk with maven or gradle, I just add the jars from the beta2 download to the libs and run from intellij.  Also nothing in the error of logcat and the replicator is processing messages.

Jens Alfke

unread,
Apr 19, 2014, 10:27:25 PM4/19/14
to mobile-c...@googlegroups.com

On Apr 19, 2014, at 6:50 PM, James Norman <james....@gmail.com> wrote:

Are there any other "current" demo applications or guides that may help with this.  I'm positive couchbase and lite is the technology we need to use.

There’s ToDo Lite, which is sort of a more advanced version of Grocery Sync with multiple lists that can be shared between users.

The Android version is still a bit behind iOS because it started development later. It’s advanced a lot past beta 2, but we decided not to release a beta 3 because it would have taken time away from development. If you’re willing to build from source, there’s probably a good recent commit you could develop from, but I’m not sure which exactly. Or if you can wait, version 1.0 will be out in a few weeks.

—Jens

James Norman

unread,
Apr 20, 2014, 12:03:48 AM4/20/14
to mobile-c...@googlegroups.com
Great, I'll take a look at that app.  I've spent a ton of time going through the install guide here:

And am having some problems with the gradle set up as well and the instructions aren't matching Android Studio, I'm getting an error
"Unspecified Dependency..." compile 'com.couchbase.cblite:CBLite:1.0.0-beta2'

And the instructions don't match the build.gradle files or what I'm seeing in Android Studio, very frustrating.

I'm not sure if bounties are OK here, but I'll put up a $100 bounty to get some sync application running on my emulator+usb device that syncs.  Let me know if anyone is interested.

James Norman

unread,
Apr 21, 2014, 12:13:51 AM4/21/14
to mobile-c...@googlegroups.com
I have the Grocery Sync app running in Android studio with both the current master branch and the beta2 of grocery-sync  and am seeing the exact behavior as outlined above.  The same messages come from the server and the applications never sync.

This leads me to believe something is wrong with my server configuration or the URL to the sync gateway.  The  android lite guide (https://github.com/couchbaselabs/GrocerySync-Android) says to modify the DATABASE_URL which doesn't exist anywhere in source.  I instead modified the SYNC_URL from  http://10.0.0.2:4984 to http://54.187.90.23:4984/sync_gateway and left everything else the same.

We're ready to run with couchbase and purchase licenses but I need to see it working to sell it to the organization.  I'm glad to pay for support to simple prototype the demo app.  If anyone can help please let me know.

Traun Leyden

unread,
Apr 21, 2014, 12:39:53 PM4/21/14
to mobile-c...@googlegroups.com

James, 

Sorry to hear you've been having such a bumpy experience and have been getting bitten by our out-of-date docs.  I'm sure we can help you get things working.

I just re-tested the latest master branch of GrocerySync-Android locally, and both push/pull replication are working for me.

To establish a "baseline", I would focus on the push replication and simply verify that docs are getting pushed to the sync gateway:

* Create a doc in grocery sync
* Verify that doc made it to the sync gateway

My local setup

Sync Gateway

Version: commit e7c0b389 from March 28
Environment: running on localhost (dev workstation)

Grocery Sync

Version: Latest master branch - 80443e47
Environment: Installed to Genymotion emulator (hence the 10.0.3.2 special "loopback" address)

Steps to verify

* Delete GrocerySync from emulator to start fresh
* Delete data/grocery-sync.walrus to start fresh
* Start sync gateway
* Start grocery sync by hitting "Debug" button in Android Studio (version 0.4.3)
* GrocerySync comes up in emulator, and list is currently empty
* Add item "foo" in GrocerySync
* Run "curl localhost:4984/grocery-sync/_all_docs" against sync gateway, and it returns: https://gist.github.com/tleyden/11148026
* Run "curl localhost:4984/grocery-sync/8ecc5ef6-8ebf-437c-bf12-5bc4dc344200" and it returns: https://gist.github.com/tleyden/11148044 

The last step verifies that the doc was indeed pushed to sync gateway.

Can you try the same steps with as close to this setup as possible and let me know the results?  Be sure to point out any "deltas" in case they are relevant.

--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/ce0c20ce-f521-41b8-913f-d306759274b7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

James Norman

unread,
Apr 21, 2014, 2:47:54 PM4/21/14
to mobile-c...@googlegroups.com
Great, thanks for the detailed response.  I think the data is not making it to the server, when I run "curl localhost:4984/grocery-sync/_all_docs" I receive:

{"rows":[
],

So the POST/PUT may not be working.
I do continue to see output in the sync-gateway application however whenever I add a row or checkbox, so the server is responding to the android app.

I have a clean couchbase install on a Ubuntu12 server.  I added a bucket called "grocery-sync" with all the defaults.

I start the sync-gateway with the following command:
./sync_gateway -url http://localhost:8091 -bucket="grocery-sync"

I added the Guest user with the following command:
curl -X PUT localhost:4985/grocery-sync/_user/GUEST --data '{"disabled":false, "admin_channels":["public"]}'

That's all on the server.  

Are there any other logs that may give some ideas or other commands on the server I need to execute?  Thanks again for all the quick help.

Also, is there a public or demo sync-gateway server that I could use to potentially rule out server related issues?

-james

James, 

To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchbase+unsubscribe@googlegroups.com.

James Norman

unread,
Apr 21, 2014, 3:29:39 PM4/21/14
to mobile-c...@googlegroups.com
Also, just an edit, I was starting the server with:
./sync_gateway -url=http://localhost:8091 -bucket="grocery-sync"

And got the same behavior.

And just to add, if I start the grocery sync app, make 2 entries, clear the cache and restart I get the following in the sync-gateway output

19:28:11.039324 HTTP:  #014: GET /grocery-sync/_local/d2ba96ef02cca253105e93d76e
343b3242439224
19:28:11.039581 HTTP: #014:     --> 404 missing  (0.0 ms)
19:28:11.039812 HTTP:  #015: GET /grocery-sync/_local/b75cad5e7cbabca195d612f2d6
f2a013bae2907c
19:28:11.039989 HTTP: #015:     --> 404 missing  (0.0 ms)
19:28:11.281168 HTTP:  #016: POST /grocery-sync/_changes

Ragu Vijaykumar

unread,
Apr 21, 2014, 3:48:44 PM4/21/14
to mobile-c...@googlegroups.com
I am no android expert, but if you are running Couchbase Server on your localhost, you can check the actual buckets via the web admin interface to see if there are files in them. Do you see any files in your buckets? This helped me in just testing whether the data was pushed to the server from a device, and at least you know one part of the process is working right.

Cheers,
Ragu

Traun Leyden

unread,
Apr 21, 2014, 3:57:24 PM4/21/14
to mobile-c...@googlegroups.com

I was able to reproduce your problem by changing my sync gateway config to match yours:

"grocery-sync": {
"server": "walrus:data",
"sync": `
function(doc){
channel(doc.channels);
}`,
"users": {
"GUEST": {"disabled": false, "admin_channels": ["public"]}
}

},


the problem is that GrocerySync application is not very "channel aware", and does not put the document into the "public" channel (or any other channel for that matter).

Can you delete your current GUEST user and either use the config I posted earlier, or run:

curl -X PUT localhost:4985/grocery-sync/_user/GUEST --data '{"disabled": false, "all_channels": ["*"], "admin_channels": ["*"]} '

and then retry from the beginning?



--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/2d4a58c4-69a0-4fd6-9fe4-a70ae23e5993%40googlegroups.com.

Traun Leyden

unread,
Apr 21, 2014, 4:16:50 PM4/21/14
to mobile-c...@googlegroups.com

I think in this case, looking directly in Couchbase Server might be misleading.  The docs are there, they just aren't visible via the Sync Gateway REST api due to reasons described above (eg, channel mismatch).

Btw I updated the GrocerySync docs to provide an example sync gateway config:

James Norman

unread,
Apr 21, 2014, 4:37:37 PM4/21/14
to mobile-c...@googlegroups.com
curl -X PUT localhost:4985/grocery-sync/_user/GUEST --data '{"disabled": false, "all_channels": ["*"], "admin_channels": ["*"]} '

Was it!  Thanks so much for the time in resolving this!

Before I was seeing some data in the buckets, but just sync messages.

I know it's in beta and documentation is hard to maintain while the software is developing/changing, so no worries there.  Thanks again and look forward to implementing this technology.

-james

Traun Leyden

unread,
Apr 21, 2014, 4:39:59 PM4/21/14
to mobile-c...@googlegroups.com
Glad to hear it worked!

By the way, your post kicked off an internal thread regarding docs, and hopefully soon we will have a "master branch" version of our official docs.


--
You received this message because you are subscribed to the Google Groups "Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mobile-couchba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mobile-couchbase/f6a0d2ad-93d2-4ad5-9bc8-516fbc638ae4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages