Authentication Error when trying to connect Sync Gateway to Couchbase Server


#1

I am new to Couchbase and databases in general, I’ve been working through the documentation to set up a CB server and a sync gateway so that I can eventually try out Couchbase Lite. I managed to run sync gateway using the ‘walrus:’ setup without any issues and I’ve added a bucket to the server called ‘mobile_bucket’. However I am running into this problem when I start Sync Gateway while trying to connect to my locally hosted Couchbase Server

MacOS 10.12.6
Couchbase Server 5.0
Sync Gateway 1.5

My sync gateway config:

{
    "log": ["*"],
    "databases": {
        "db": {
            "server": "http://127.0.0.1:8091",
            "bucket": "mobile_bucket",
            "users": { "GUEST": { "disabled": false, "admin_channels": ["*"] } }
        }
    }
}

Terminal Output:

Braydens-MacBook-Pro:bin brayden$ ./sync_gateway sync-gateway-config2.json
2017-10-26T10:26:45.884-04:00 Enabling logging: [*]
2017-10-26T10:26:45.884-04:00 ==== Couchbase Sync Gateway/1.5.0(494;5b6b5b9) ====
2017-10-26T10:26:45.884-04:00 Configured process to allow 5000 open file descriptors
2017-10-26T10:26:45.884-04:00 Opening db /db as bucket "mobile_bucket", pool "default", server <http://127.0.0.1:8091>
2017-10-26T10:26:45.884-04:00 GoCBCustomSGTranscoder Opening Couchbase database mobile_bucket on <http://127.0.0.1:8091> as user "mobile_bucket"
2017-10-26T10:26:45.886-04:00 WARNING: Error opening bucket: mobile_bucket.  Error: authentication error -- base.GetCouchbaseBucketGoCB() at bucket_gocb.go:117
2017-10-26T10:26:45.886-04:00 Debug: RetryLoop retrying Attempt to connect to bucket : mobile_bucket after 5 ms.

… continued …

2017-10-26T10:15:37.235-04:00 GoCBCustomSGTranscoder Opening Couchbase database mobile_bucket on <http://127.0.0.1:8091> as user "mobile_bucket"
2017-10-26T10:15:37.237-04:00 WARNING: Error opening bucket: mobile_bucket.  Error: authentication error -- base.GetCouchbaseBucketGoCB() at bucket_gocb.go:117
2017-10-26T10:15:37.237-04:00 WARNING: RetryLoop for Attempt to connect to bucket : mobile_bucket giving up after 14 attempts -- base.RetryLoop() at util.go:293
2017-10-26T10:15:37.237-04:00 FATAL: Error opening database: 502  Unable to connect to Couchbase Server (connection refused). Please ensure it is running and reachable at the configured host and port.  Detailed error: authentication error -- rest.RunServer() at config.go:761

#2

you should add
username and password in db object.
FYI
https://developer.couchbase.com/documentation/mobile/1.5/whatsnew.html

With Role Based Access Control (RBAC) newly introduced in Couchbase Server 5.0, you’ll need to create a new user with authorized access to the bucket. Choose the Security > Add User option in the Couchbase Server Admin and select the Bucket Full Access and Read Only Admin roles.
Start Sync Gateway with the following configuration file.

{
“databases”: {
“db”: {
“bucket”: “my-bucket”,
> “username”: “my-user”,
> “password”: “my-password”,
“server”: “http://localhost:8091”,
“enable_shared_bucket_access”: true,
“import_docs”: “continuous”
}
}
}
There are two properties to keep in mind. The enable_shared_bucket_access property is used to disable the default behaviour. And the import_docs property to specify that this Sync Gateway node should perform import processing of incoming documents. Note that in a clustered environment, only 1 node should use the import_docs property.


#3

Thank you for the information, I have it working now


#4

what does only one node should use import_docs ?
can you elobarate more !
thanks


#5

That’s referring to the number of Sync Gateway nodes. When Sync Gateway “imports” docs from Couchbase Server, it adds the meta data needed for Couchbase Mobile. You only want one SG instance doing that.