Why can I only see changes on the SG Admin port (4985)

47 views
Skip to first unread message

John Carr

unread,
Jan 24, 2015, 9:40:23 PM1/24/15
to mobile-c...@googlegroups.com
I'm a newbie to the entire CouchBase suite.  I've set up CouchBase, Sync_Gateway and CouchBase-Lite seemingly successfully.  I can get the mobile device to push and pull doc changes (via SG) just fine BUT only if I use SG's Admin port (4985).  If I use the REST port (4984) I get nothing.

Here is the SG config file:

root@s1-anithon:~# cat /home/sync_gateway/sync_gateway.json
{

   "inferface": ":4984",
   "adminInterface": ":4985",
   "log": ["REST"],
   "verbose": true,
   "databases": {
      "sync_gateway": {
         "server": "http://127.0.0.1:8091",
         "bucket": "sync_gateway",
         "sync": `function(doc) {channel(doc.channels);}`
      },
      "gamesim-sample": {
         "server": "http://127.0.0.1:8091",
         "bucket": "gamesim-sample",
         "sync": `function(doc) {channel(doc.channels);}`
      }
   }

I bring up one terminal window on the server running SG and enter this command:

root@s1-anithon:~# curl 'http://carrjd12:fred11@localhost:4985/sync_gateway/_changes?feed=continuous&style=all_docs&since=0&heartbeat=10000'
{"seq":2,"id":"1cadb7dc-7def-442d-9647-2b2e8ae0ed9f","changes":[{"rev":"2-d036fde157e272025678c59b1469840c"}]}
{"seq":3,"id":"f3a44043-6923-47b0-95e0-2cfe8a2792d7","changes":[{"rev":"2-759cab1a1242ffc36b36b2d7c79f1d62"}]}
...
{"seq":122,"id":"36480aeec3017071cb7181de6fd0e8b8","changes":[{"rev":"1-cd809becc169215072fd567eebd8b8de"}]}
{"seq":123,"id":"c9bb38bcb74cca13dad8c559e012ea41","changes":[{"rev":"1-cd809becc169215072fd567eebd8b8de"}]}


With it listening, I then enter this command in another terminal window

root@s1-anithon:~# curl -v -X POST 'http://carrjd12:fred11@localhost:4984/sync_gateway/' -d '{"foo": "bar"}' -H "Content-Type: application/json"
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4984 (#0)
* Server auth using Basic with user 'carrjd12'
> POST /sync_gateway/ HTTP/1.1
> Authorization: Basic Y2FycmpkMTI6ZnJlZDEx
> User-Agent: curl/7.35.0
> Host: localhost:4984
> Accept: */*
> Content-Type: application/json
> Content-Length: 14
>
* upload completely sent off: 14 out of 14 bytes
< HTTP/1.1 200 OK
< Content-Length: 94
< Content-Type: application/json
< Etag: 1-cd809becc169215072fd567eebd8b8de
< Location: 594a4e018530e650361ea3b0b7c61e7e
* Server Couchbase Sync Gateway/1.00 is not blacklisted
< Server: Couchbase Sync Gateway/1.00
< Date: Sun, 25 Jan 2015 02:11:53 GMT
<
* Connection #0 to host localhost left intact
{"id":"594a4e018530e650361ea3b0b7c61e7e","ok":true,"rev":"1-cd809becc169215072fd567eebd8b8de"}

Which causes this to appear in the listening terminal window

{"seq":124,"id":"594a4e018530e650361ea3b0b7c61e7e","changes":[{"rev":"1-cd809becc169215072fd567eebd8b8de"}]}

So it works as expected, but I have to use the Admin port to listen on. If I switch to the REST port (4984) this is what I get

root@s1-anithon:~# curl 'http://carrjd12:fred11@localhost:4984/sync_gateway/_changes?feed=continuous&style=all_docs&since=0&heartbeat=10000'
{"seq":117,"id":"_user/carrjd12","changes":[]}



When I go to the other terminal window and enter the same command as previously

root@s1-anithon:~# curl -v -X POST 'http://carrjd12:fred11@localhost:4984/sync_gateway/' -d '{"foo": "bar"}' -H "Content-Type: application/json"
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 4984 (#0)
* Server auth using Basic with user 'carrjd12'
> POST /sync_gateway/ HTTP/1.1
> Authorization: Basic Y2FycmpkMTI6ZnJlZDEx
> User-Agent: curl/7.35.0
> Host: localhost:4984
> Accept: */*
> Content-Type: application/json
> Content-Length: 14
>
* upload completely sent off: 14 out of 14 bytes
< HTTP/1.1 200 OK
< Content-Length: 94
< Content-Type: application/json
< Etag: 1-cd809becc169215072fd567eebd8b8de
< Location: 4763b15eccc3686fa1a8da6b74fdd51d
* Server Couchbase Sync Gateway/1.00 is not blacklisted
< Server: Couchbase Sync Gateway/1.00
< Date: Sun, 25 Jan 2015 02:18:45 GMT
<
* Connection #0 to host localhost left intact
{"id":"4763b15eccc3686fa1a8da6b74fdd51d","ok":true,"rev":"1-cd809becc169215072fd567eebd8b8de"}

I get nothing except for a new line in the window listening on port 4984.  I checked the database, the document has been added. 

I see examples all over the Internet of people using port 4984 to listen on and being successful.  

So what am I not understand or what do I have configured wrong?

Jens Alfke

unread,
Jan 25, 2015, 5:46:39 PM1/25/15
to mobile-c...@googlegroups.com

On Jan 24, 2015, at 6:40 PM, John Carr <jdc...@gmail.com> wrote:

I'm a newbie to the entire CouchBase suite.  I've set up CouchBase, Sync_Gateway and CouchBase-Lite seemingly successfully.  I can get the mobile device to push and pull doc changes (via SG) just fine BUT only if I use SG's Admin port (4985).  If I use the REST port (4984) I get nothing.

This is a fairly common getting-started problem. What's probably happening is that the documents you put in the database are not being assigned to any channels that are accessible by the user account doing the pulling. Possible solutions:

* Edit the config file to give the user accounts access to the "*" channel, so they can see all docs.
* Enable "admin party" mode by enabling the "GUEST" account and giving it access to "*"; then you don't have to worry about logins at all.
* If you're using the default sync function, add a "channel" property to every doc, then in the config file give the user accounts access to the channels the docs are in.

Hope this makes sense; feel free to ask for clarification if the docs aren't helping.

(And I'm wondering if we shouldn't change the default settings in SG so new users don't hit this issue. Maybe have it default to admin-party?)

—Jens

Traun Leyden

unread,
Jan 26, 2015, 9:39:07 AM1/26/15
to mobile-c...@googlegroups.com
If we do, I think we should come up with a clearer name than "admin party".

--
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/E3C6B21B-C774-4EF9-B538-24A137FF005C%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Jens Alfke

unread,
Jan 26, 2015, 11:33:12 AM1/26/15
to mobile-c...@googlegroups.com

On Jan 26, 2015, at 6:39 AM, Traun Leyden <traun....@gmail.com> wrote:

If we do, I think we should come up with a clearer name than "admin party".

"Anarchy in the SG!" (It's coming someday, maybe)

—Jens

John Carr

unread,
Jan 27, 2015, 3:23:35 PM1/27/15
to mobile-c...@googlegroups.com

Thanks Jens.  That gave me the answer (in a round about way).

I entered this at the command line

curl -X PUT 'http://localhost:4985/sync_gateway/_user/carrjd12' --data '{"admin_channels":["android123"]}'

then started listening in another window on port 4984 via: 

 curl 'http://carrjd12:fred11@localhost:4984/sync_gateway/_changes?feed=continuous&style=all_docs&since=0&heartbeat=10000'

and then posted this:

curl -v -X POST 'http://carrjd12:fred11@localhost:4984/sync_gateway/' -d '{"channels":["android123"], "Money":"None"}' -H "Content-Type: application/json"

And the window listening for changes displayed the added document.  Awesome!

But I'd much rather have followed your suggestion to

* Edit the config file to give the user accounts access to the "*" channel, so they can see all docs

Unfortunately, in my searching of the docs (and my ignorance) I couldn't figure out the syntax/command that I needed to add to the config file (I'm assuming the sync_gateway.json config file) to make this happen. What would that be?

Jens Alfke

unread,
Jan 27, 2015, 10:55:13 PM1/27/15
to mobile-c...@googlegroups.com

On Jan 27, 2015, at 12:23 PM, John Carr <jdc...@gmail.com> wrote:

Unfortunately, in my searching of the docs (and my ignorance) I couldn't figure out the syntax/command that I needed to add to the config file (I'm assuming the sync_gateway.json config file) to make this happen. What would that be?

"Admin party" looks like:
"users": {
"GUEST": {"disabled": false, "admin_channels": ["*"] }
}
…inside the config object for a database.

If you want to give a specific user access to all channels, it would be like
"users": {
"jens": {"admin_channels": ["*"] }
}
(you don't need "disabled":false because a non-guest user account is enabled by default if it's configured.)

—Jens
Reply all
Reply to author
Forward
0 new messages