N1QL queries fail silently when N1QL port is blocked


#1

Hi!

I’m maintainer for the Couchbase/Drupal 8 integration.

Recently on a deployment I found out that if the port used to run N1QL queries is blocked (8093) when you try to run a N1QL the call to $bucket->query() will return AN EMPTY ARRAY instead of throwing a timeout exception.

Steps to reproduce:

  1. Build a simple PHP script that runs an N1QL query against a remote Couchbase Server (4.1) using the latest PHP SDK, such as this one:

    $cluster = new \CouchbaseCluster(‘couchbase://127.0.0.1’);
    $bucket = $cluster->openBucket(‘couch’, ‘couch’);
    $query = \CouchbaseN1qlQuery::fromString(“SELECT COUNT(*) AS RESULT FROM couch WHERE event = ‘user.failed_login_ip’”);
    $result = $bucket->query($query, array(), FALSE);
    echo json_encode($result);

This will output:

[{“RESULT”:0}]

  1. Block port 8093 in the couchbase server.

  2. Try to run the script, it will output:

[]

The expected result is that an exception is thrown indicating that the the service is down or not reachable.


#2

Hey @davidbcn,

This does appear to be a bug. I have filed an issue here to track the issue: https://issues.couchbase.com/browse/PCBC-388.

Cheers, Brett