How do I connect sync-gateway to couchbase running on a different server?


#1

I have port 8091 open on the couchbase server I am trying to connect to (Couchbase v3.0.2) but when I run sync gateway on a different server (v1.1.0) it says it cannot connect. Port 8091 is the only port open, does sync gateway use other ports that need to be open as well? My sync gateway log shows this:

2015-09-04T13:24:07.162Z Enabling logging: [HTTP Access CRUD]
2015-09-04T13:24:07.162Z ==== Couchbase Sync Gateway/1.1.0(28;86f028c) ====
2015-09-04T13:24:07.162Z Configured Go to use all 4 CPUs; setenv GOMAXPROCS to override this
2015-09-04T13:24:07.162Z Configured process to allow 20000 open file descriptors
2015-09-04T13:24:07.162Z Opening db /todos as bucket "todos", pool "default", server <http://<hostname>:8091>
2015-09-04T13:24:07.163Z Opening Couchbase database todos on <http://<hostname>:8091>
2015/09/04 13:24:07  Trying with selected node 0

If I try to retrieve a document though with something like this: curl localhost:4985/todos/_user/<user id> it just says it cannot connect to host, which in this case means sync gateway but since it is running I take to mean that sync gateway cannot connect to couchbase server.


#2

@alexegli

This page has the full list of CBS ports, I think that SG will need access to the ports in the ‘node to client’ column.

Andy


#3

I’m having a similar problem starting sync_gateway on docker. I have a container running couchbase:community-4.0.0 and another running a sync_gateway image based on couchbase/sync-gateway but with a config file. The following ports are open on the sync gateway server: 8091, 8092, 8093, 11207, 11209, 11210, 11211, 11214, 11215, 18091, 18092, 4369.

The sync gateway seems to hang on Trying with selected node 0 and then crashes. Here are the logs:

2015-11-24T18:39:25.242601280Z 2015-11-24T18:39:25.239Z Enabling logging: [REST REST+ HTTP HTTP+]
2015-11-24T18:39:25.242663689Z 2015-11-24T18:39:25.242Z ==== Couchbase Sync Gateway/HEAD(nobranch)(86f028c) ====
2015-11-24T18:39:25.242909562Z 2015-11-24T18:39:25.242Z Opening db /sync_gateway_2 as bucket "sync_gateway", pool "default", server <http://couchbase-server:8091>
2015-11-24T18:39:25.244069943Z 2015-11-24T18:39:25.243Z Opening Couchbase database sync_gateway on <http://couchbase-server:8091>
2015-11-24T18:39:29.410305525Z 2015/11/24 18:39:29  HTTP request returned error Get http://couchbase-server:8091/pools: dial tcp 10.7.0.3:8091: no route to host
2015-11-24T18:39:29.410633827Z 2015-11-24T18:39:29.410Z FATAL: Error opening database: 502 Unable to connect to server: Get http://couchbase-server:8091/pools: dial tcp 10.7.0.3:8091: no route to host -- rest.RunServer() at config.go:480
2015-11-24T18:39:29.681888644Z 2015-11-24T18:39:29.681Z Enabling logging: [REST REST+ HTTP HTTP+]
2015-11-24T18:39:29.683410944Z 2015-11-24T18:39:29.683Z ==== Couchbase Sync Gateway/HEAD(nobranch)(86f028c) ====
2015-11-24T18:39:29.683500407Z 2015-11-24T18:39:29.683Z Opening db /sync_gateway_2 as bucket "sync_gateway", pool "default", server <http://couchbase-server:8091>
2015-11-24T18:39:29.683692778Z 2015-11-24T18:39:29.683Z Opening Couchbase database sync_gateway on <http://couchbase-server:8091>
2015-11-24T18:39:29.699203036Z 2015/11/24 18:39:29  Trying with selected node 0
2015-11-24T18:39:29.805510425Z 2015/11/24 18:39:29  Trying with selected node 0
2015-11-24T18:43:03.055845795Z 2015/11/24 18:43:03 go-couchbase: call to Do("_sync:seq") in github.com/couchbase/go-couchbase.(*Bucket).Incr took 3m33.139973623s
2015-11-24T18:43:03.090055809Z 2015-11-24T18:43:03.088Z WARNING: Error from Incr in sequence allocator (0) - attempt (1/3): MCResponse status=KEY_ENOENT, opcode=INCREMENT, opaque=0, msg: Not found -- db.(*sequenceAllocator).incrWithRetry() at sequence_allocator.go:86
2015-11-24T18:44:02.444601076Z 2015/11/24 18:44:02 go-couchbase: call to Do("_sync:seq") in github.com/couchbase/go-couchbase.(*Bucket).Incr took 59.34373353s
2015-11-24T18:44:02.444859534Z 2015-11-24T18:44:02.444Z WARNING: Error from Incr in sequence allocator (0) - attempt (2/3): MCResponse status=KEY_ENOENT, opcode=INCREMENT, opaque=0, msg: Not found -- db.(*sequenceAllocator).incrWithRetry() at sequence_allocator.go:86

#4

The ‘Trying with selected node 0’ messages are normal during connection, so I don’t think those are related. It looks like operations against the Couchbase server are timing out (the slow incr operations).

I’d expect it to fail before that if it was a port access issue, although you could try enabling additional Sync Gateway logging to see if that sheds any light on the issue.


#6

Your logs look very different from mine, so it may not be the same issue. My issue was the ports, sync gateway needs a lot more than just port 8091. Azure blocks everything I don’t explicitly open unless the VMs are in the same virtual network, so I just moved the sync gateway instance to a VM in the same virtual network as my target couchbase server. Make sure you have no firewalls or blocked ports between sync gateway and your couchbase server.


#7

Was this resolved? I am having a similar issue where I have only port 8091 open between the sync gateway server and the db server, and I an error when trying to open the database


#8

The link Andy provided above looks like it’s disappeared. The ‘node to client’ ports listed here will need to be open for SG to communicate with Couchbase Server:
http://docs.couchbase.com/admin/admin/Install/install-networkPorts.html


#9

Thanks, Adam! I’ve added a couple already and I can see the requests coming through without any issue