trying to connect to sync.couchbasecloud.com

101 views
Skip to first unread message

Milt Grinberg

unread,
Jul 14, 2014, 7:32:11 PM7/14/14
to mobile-c...@googlegroups.com
I posted this to the couchbasecloud forum about 10 days ago with no response.  So I figure it is not being monitored by couchbase.  This forum appears to be monitored by couchbase personnel.  


I am trying to connect to the couchbasecloud (i.e.,
http://sync.couchbasecloud.com/mydbname

I then get an Authentication required

'A username and password are being requested by http://sync.couchbasecloud.com. The site says: "Couchbase Sync Gateway"'

I have tried to use my login to the couchbasecloud
(i.e. couchbasecloud.com website) with NO success.

What should I be entering in the dialog box and/or how do I setup a login for use while testing the use of sync-gateway and the couchbasecloud.

I can see the dashboard for the database when I login to the couchbasecloud  website

Thanks

Jens Alfke

unread,
Jul 14, 2014, 7:49:36 PM7/14/14
to mobile-c...@googlegroups.com

On Jul 14, 2014, at 4:32 PM, Milt Grinberg <milt...@gmail.com> wrote:

> I am trying to connect to the couchbasecloud (i.e.,
> http://sync.couchbasecloud.com/mydbname

> What should I be entering in the dialog box and/or how do I setup a login for use while testing the use of sync-gateway and the couchbasecloud.

That’s a URL for the sync API, i.e. what a mobile app would be connecting to to sync with the server. The credentials to provide there are those for any user account you created in your Sync Gateway instance (by doing a PUT to /mydbname/username at the admin access URL.)

Also, a web browser’s not a good tool for trying out the API. curl or httpie would be better.

—Jens

Milt Grinberg

unread,
Jul 15, 2014, 5:32:55 PM7/15/14
to mobile-c...@googlegroups.com
I'm not getting something correct.  So let me try to explain everything I'm doing and see where I am going wrong.

My android code is the following:
   
   ```   
    private static final String SYNC_URL = "http://sync.couchbasecloud.com/mydb/";
    private static final String SYNC_ACCOUNT = "milt";
    private static final String SYNC_PASSWORD = "milt";
    URL url = new URL(SYNC_URL);
    Replication push = database.createPushReplication(url);
    Replication pull = database.createPullReplication(url);
    Authenticator auth = new BasicAuthenticator(SYNC_ACCOUNT, SYNC_PASSWORD);
    push.setAuthenticator(auth);
    pull.setAuthenticator(auth);
    push.start();
    pull.start();
```

I have setup in the couchbasecloud the sync function
```
{
    "interface":":4984",
    "adminInterface":":4985",
    "log":["REST"],
    "databases":{
    "mydb":{
        "server":"http://localhost:8091",
  "users": {"GUEST":{"disabled" :false},
"milt":{"password" : "milt"}
},
        "bucket":"sync_gateway",
        "sync":`function(doc) {channel(doc.channels);}`
    }
}
```

When I run the code in the android app, I get the following errors:
```
07-15 14:00:22.328 E/RemoteRequest﹕ Got error status: 401 for org.apache.http.client.methods.HttpGet@41700d78.  Reason: Unauthorized
07-15 14:00:22.335 E/RemoteRequest﹕ Got error status: 401 for org.apache.http.client.methods.HttpGet@41601420.  Reason: Unauthorized
07-15 14:00:22.406 E/Sync﹕ com.couchbase.lite.replicator.Replication$4@417008d0: Session check failed
    org.apache.http.client.HttpResponseException: Unauthorized
            at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:229)
            at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:106)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)
07-15 14:00:22.414 E/Sync﹕ Puller@416da910[http://sync.couchbasecloud.com/mydb/]: Progress: set error = org.apache.http.client.HttpResponseException: Unauthorized
07-15 14:00:22.476 E/Sync﹕ com.couchbase.lite.replicator.Replication$4@41615930: Session check failed
    org.apache.http.client.HttpResponseException: Unauthorized
            at com.couchbase.lite.support.RemoteRequest.executeRequest(RemoteRequest.java:229)
            at com.couchbase.lite.support.RemoteRequest.run(RemoteRequest.java:106)
            at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:442)
            at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305)
            at java.util.concurrent.FutureTask.run(FutureTask.java:137)
            at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076)
            at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
            at java.lang.Thread.run(Thread.java:856)
07-15 14:00:22.492 E/Sync﹕ Pusher@416d6db8[http://sync.couchbasecloud.com/mydb/]: Progress: set error = org.apache.http.client.HttpResponseException: Unauthorized
```

I must be doing something incorrectly.  Please help.

Thanks, Milt

Jens Alfke

unread,
Jul 15, 2014, 8:54:42 PM7/15/14
to mobile-c...@googlegroups.com

On Jul 15, 2014, at 2:32 PM, Milt Grinberg <milt...@gmail.com> wrote:

I have setup in the couchbasecloud the sync function
```
{
    "interface":":4984",

That’s not a sync function, that’s a JSON configuration file. A sync function is a JavaScript function. In the config file you showed, it’s "function(doc) {channel(doc.channels);}”.

Couchbase Cloud doesn’t give you direct access to the configuration file; that's for configuring your own instance of Sync Gateway running on your server. If you pasted one of those into the textfield where the sync function should go, it’s not going to work. :(

Unfortunately Couchbase Cloud doesn’t have a GUI for configuring users. You’ll need to use the admin REST API for that (as described in the gateway docs.)

—Jens

Traun Leyden

unread,
Jul 17, 2014, 2:41:05 PM7/17/14
to mobile-c...@googlegroups.com
Milt,

Couchbase Cloud is fairly limited, so I'd recommend that you run your own Sync Gateway.  To that end, I recently wrote up a blog article on how to get Sync Gateway running on Google Compute Engine / Docker:


and am planning to adapt this to EC2.

Just curious, what would be your preferred OS / IAAS to run Sync Gateway?





--
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/0A06C502-365D-4CAE-B896-74AF202EA1C9%40couchbase.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages