Can connect to bucket but timeout when I query


#1

I have a php app I have been testing against our test server with no issues. I have been connecting to the server as follows:

$cluster = new CouchbaseCluster($couchbaseCluster);
$cluster->authenticateAs($couchbaseUser, $couchbasePassword);
try {
$bucket = $cluster->openBucket($bucketName);
}
catch(Exception $e) {
errorLogging("Unable to connect to couchbase: " . $couchbaseCluster);
}

Our test environment has a single server.

After opening the bucket I am able to query as follows:
$sqlQuery = “SELECT *
FROM object USE KEYS ‘doc:c31c059c-b173-40d4-bf6a-89bdc5327c5a’”;
$query = CouchbaseN1qlQuery::fromString($sqlQuery);
$result = $bucket->query($query);

which works in all my cases.

My prod environment is a cluster with 3 servers. Both the test and prod are using the same couchbase server - Enterprise 5.1.1

When I try to use my production server I am able to open the bucket, but when I try to run a query I get the following connection errors:

[cb,WARN] (server L:502 I:222435566) NOHOST:NOPORT (CTX=0x0,SRV=0x7ffd8a0a0ab0,IX=0) Failing command (pkt=0x7ffd8b002a00, opaque=0, opcode=0xb5) with error LCB_ETIMEDOUT (0x17)
[cb,EROR] (connection L:156 I:222435566) <172.31.61.4:11210> (SOCK=00000000585df311) Failed to establish connection: LCB_ETIMEDOUT (0x17), os errno=0
[cb,EROR] (cccp L:165 I:222435566) NOHOST:NOPORT (CTX=0x0,) Could not get configuration: LCB_ETIMEDOUT (0x17)
[cb,EROR] (connection L:156 I:222435566) <172.31.67.72:11210> (SOCK=0000000000010e6a) Failed to establish connection: LCB_ETIMEDOUT (0x17), os errno=0
[cb,EROR] (server L:628 I:222435566) NOHOST:NOPORT (CTX=0x0,SRV=0x7ffd8a0a1c40,IX=1) Connection attempt failed. Received LCB_ETIMEDOUT (0x17) from libcouchbase, received 0 from operating system

I am able to make the queries in the CB console.

ideas?
thanks
Tim


#2

Usually first thing I would check is the firewall settings on servers and client machines. When you using Admin UI, you are connecting through port 8091, but the SDK might use several other ports. You can find full list here:

https://developer.couchbase.com/documentation/server/current/install/install-ports.html

The second thing to check is that the cluster configured to use addresses visible by client machines. For example cluster might be in virtual network, and use internal IP addresses, which cannot be resolved from the clients in different network. If you are using AWS you can get more information about networking here

https://developer.couchbase.com/documentation/server/current/cloud/couchbase-aws-best-practices.html

If neither of the options, let me know and we will try to dig deeper.


#3

Thanks. We will look into more and I will get back to you!


#4

Does Couchbase have a guide on setting up an aws VPC to use with existing ec2 instances containing CB server nodes


#5

Hi Folks,

I work with Tim and Brayden. In retrospect this is a bit of a facepalm moment but I’ll post it here incase anyone else stumbles on this issue:

We run our CB Cluster and Web front end in the same VPC on AWS. In our code we were trying to connect to the CB Cluster using our public domains/IPs when we should have been using the private/internal IPs so thst they can chatter amongst themselves within the VPC.

After that change we have our web front end talking to our CB cluster.

Thanks everyone that took the time to read and reply to our post.

Jason . :man_facepalming:


#6

Thanks for the update, glad you were able to solve it!