Connecting to SyncGateway with Xamarin Android project.

65 views
Skip to first unread message

Mikael Gyth

unread,
Jun 9, 2014, 5:08:45 AM6/9/14
to mobile-c...@googlegroups.com
Hello.
I have set up a SyncGateway witch should be configured correctly.
And I have created a test app for Android using the Couchbase for Mobile package for Xamarin.
I am able to store and retrieve values from the phones Couchbase Lite database.
But when I try to sync the the phones database with the SyncGateway I have set up I get a "404 missing (0,0 ms)" message and I'm stuck on why this is happening.

This is the server output when the phone attempts to sync
10:55:41.214112 Starting server on :4984 ...
2014/06/09 10:55:49 go-couchbase: call to ViewCustom("sync_gateway", "access") i
.2484ms
2014/06/09 10:55:49 go-couchbase: call to ViewCustom("sync_gateway", "access") i
.243ms
10:55:49.411340 HTTP:  #001: GET /default/_local/69b53adb28fb91575d9a2cf5099697c
1e66884ed
10:55:49.411340 HTTP: #001:     --> 404 missing  (0.0 ms)
10:55:49.423351 HTTP:  #002: GET /default/_local/ad114d3c7723fe994d8442cb2dda67e
c3c21e31a
10:55:49.423351 HTTP: #002:     --> 404 missing  (0.0 ms)
10:55:49.427357 HTTP:  #003: GET /default/_changes?feed=longpoll&limit=50&heartb
eat=300000&style=all_docs


this is my config file:

{
   "interface":":4984",
   "adminInterface":":4985",
   "log":["CRUD", "REST+"],
   
   "pretty": true,
   "verbose": true,
   "databases":{
      
      "default":{
"users": {
         "GUEST": {"disabled": false},
 "app": {"password": "password", "name": "application"}
      },
         "server":"http://localhost:8091",
         "bucket":"default",
         "sync":`function(doc) {channel(doc.channels);}`
      }
   }
}

and this is the url i use in the phone to contact the server:
http://app:pass...@xxx.xxx.xxx.xxx:4984/default


Can anyone shed some light on what is going wrong?

Jens Alfke

unread,
Jun 9, 2014, 10:53:05 AM6/9/14
to mobile-c...@googlegroups.com

On Jun 9, 2014, at 2:08 AM, Mikael Gyth <gythm...@gmail.com> wrote:

But when I try to sync the the phones database with the SyncGateway I have set up I get a "404 missing (0,0 ms)" message and I'm stuck on why this is happening.

The 404 you showed is expected. The client is reading the checkpoint data stored on the gateway, and since it’s the first time syncing, there isn’t any checkpoint yet. (You can tell a checkpoint document because its ID consists of “_local/“ followed by a 40-digit hex number.)

Is anything actually going wrong besides the 404 log?

—Jens

Mikael Gyth

unread,
Jun 9, 2014, 1:35:54 PM6/9/14
to mobile-c...@googlegroups.com
Hello.

No, there is no errors anywhere that I can see, the app functions as normal (No errors, freezes or any other abnormal behavior). Other than the fact that the databases do not seem to sync. Neither the documents I have stored on the phone or the document i have created on the sever gets synchronized either way.

Are there any additional steps that need to be taken to set up the server? Right now I have just installed it and run trough the setup process, using the default values. The "default" bucket contains one Document (does the ID i give the document matter, I choose "1" for the document i created) that I have created and the ones I think come from the config file ( _sync:role, _sync:seq, _sync:syncdata and _sync:user).

On the phone I am using the same Push/Pull code as is used in the Android example project that came with the Package for Xamarin ( http://components.xamarin.com/view/couchbase-lite/)

Mikael Gyth

unread,
Jun 9, 2014, 3:09:44 PM6/9/14
to mobile-c...@googlegroups.com
Now I'm getting this in the log of the gateway:

21:07:33.722907 Changes: MultiChangesFeed({*}, {Since:0 Limit:50 C
IncludeDocs:false Wait:true Continuous:false Terminator:0xc0841767
21:07:33.723909 Changes+: MultiChangesFeed: channels expand to  ..
21:07:33.723909 Changes+: MultiChangesFeed waiting...
21:07:33.723909 Changes+: Waiting for "default"'s count to pass 5

Witch I think is moving forward?

Mikael Gyth

unread,
Jun 12, 2014, 2:27:51 AM6/12/14
to mobile-c...@googlegroups.com
When I added the "channel" property to my Couchbase Lite documents they where synced with the database. Found it in the old documentation for Sync Gateway.

Jens Alfke

unread,
Jun 12, 2014, 11:31:27 AM6/12/14
to mobile-c...@googlegroups.com

On Jun 11, 2014, at 11:27 PM, Mikael Gyth <gythm...@gmail.com> wrote:

When I added the "channel" property to my Couchbase Lite documents they where synced with the database. Found it in the old documentation for Sync Gateway.

Then the source of your problem was that your docs weren’t being added to any channels, so the other clients didn’t have access to them.

Sounds like you’re using the default sync function in your gateway config, then? That function just adds docs to channels based on the strings found in the “channels” property of the document. In a real app you’ll want to design a sync function that uses appropriate properties of the documents to assign channels.

—Jens
Reply all
Reply to author
Forward
0 new messages