PHP : connection to server is erroring

Hi,

I am trying to connect to couchbase server in PHP as below :
$cluster = new CouchbaseCluster(“ip_address:8091”);
$bucket = $cluster->openBucket(“default”);

but I am getting error as below :

Type: CouchbaseException

Message: LCB_NETWORK_ERROR: Generic network failure. Enable detailed error codes (via LCB_CNTL_DETAILED_ERRCODES, or via detailed_errcodes in the connection string) and/or enable logging to get more information

Filename: [CouchbaseNative]/CouchbaseBucket.class.php

Line Number: 76

Kindly help.

Could you make sure that you have access to Couchbase Server ports?
http://developer.couchbase.com/documentation/server/current/install/install-ports.html

Also make sure that the server was configured using IP address also accessible by the client, e.g. public AWS interface for the clients outside AWS network?
http://developer.couchbase.com/documentation/server/current/install/hostnames.html

To verify that try to connect to it with telnet like this telnet ip_address 11210. In case of failure, you would see:

$ telnet localhost 11210
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
telnet: Unable to connect to remote host

But if everything seems okay, it will just wait for commands:

$ telnet  192.168.1.194 11210
Trying 192.168.1.194...
Connected to 192.168.1.194.
Escape character is '^]'.

Also if you would enable defailed error codes, you would see this in PHP:

<?php
$cluster = new CouchbaseCluster("localhost:8091?detailed_errcodes=true");
$bucket = $cluster->openBucket("default");
Fatal error: Uncaught exception 'CouchbaseException' with message 'LCB_ECONNREFUSED: The remote host refused the connection. Is the service up?' in [CouchbaseNative]/CouchbaseBucket.class.php:76
Stack trace:
#0 [CouchbaseNative]/CouchbaseBucket.class.php(76): _CouchbaseBucket->__construct('localhost:8091/...', 'default', '')
#1 [CouchbaseNative]/CouchbaseCluster.class.php(70): CouchbaseBucket->__construct('localhost:8091/...', 'default', '', NULL)
#2 /tmp/test.php(3): CouchbaseCluster->openBucket('default')
#3 {main}
  thrown in [CouchbaseNative]/CouchbaseBucket.class.php on line 76

Which also means that the IP or ports are not accessible.

Hi avsej,

I tried telnet <ip_address> 11210 and it got connected. I tried below code as well but I am still facing the same issue. Below is the error i recieved :

$cluster = new CouchbaseCluster(“localhost:8091?detailed_errcodes=true”);
$bucket = $cluster->openBucket(“default”);

An uncaught Exception was encountered

Type: CouchbaseException

Message: LCB_NETWORK_ERROR: Generic network failure. Enable detailed error codes (via LCB_CNTL_DETAILED_ERRCODES, or via `detailed_errcodes` in the connection string) and/or enable logging to get more information

Filename: [CouchbaseNative]/CouchbaseBucket.class.php

Line Number: 76

Kindly help.

You didn’t specified the client version are you using. The most recent is 2.2.1, what are you using?

Hi,

We are using 2.2.1.

Thanks,

Hi,

Do you need any more information from my end. Kindly help

could you capture tcp packets for ports 8091 and 11210 during script run (like with tcpdump or tshark)?

Hi,

I tried the tcpdump on port 8091 and 11210 but could not get any tcp packets when I hit my url which connects to the couchbase server.

below is the script I ran :

sudo tcpdump port 8091
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes
^Z
[2]+  Stopped                 sudo tcpdump port 8091
[rameshnittali123@instance-1 ~]$ sudo tcpdump port 11210 
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 65535 bytes

Below is the screen shot when I hit my url that connects to Couchbase.

Could you make sure that you are capturing correct interfaces? You can enumerate with in -i option, and redirect output into file with -w, for example

sudo tcpdump -w output.tcpdump -i wlp1s0 -i lo 'tcp port 8091 or tcp port 11210'

strange, attachment url gives 404, could you send it to sergey@couchbase.com?

Hello,
Have sent the file to mentioned mail id.

Please let me know if you have recieved it correctly.

From tcp dump it seems like 11210 port is not reachable. Could you check that there is no firewall rules blocking it? Also could you confirm that both server and client on the same machine (i.e. you are connecting to localhost in PHP script)?

Hi Avsej,
The port 11210 seems to listening . I ran below command to see if port is reachable.
And yes client and server is in same machine. I have tried connecting with localhost and as well as with ip address. But still not able to connect.

$ sudo netstat -anp | grep 11210
tcp        0      0 0.0.0.0:11210           0.0.0.0:*               LISTEN      1720/memcached      
tcp        0      0 127.0.0.1:41954         127.0.0.1:11210         ESTABLISHED 1663/moxi           
tcp        0      0 127.0.0.1:11210         127.0.0.1:46576         ESTABLISHED 1720/memcached      
tcp        0      0 127.0.0.1:11210         127.0.0.1:41954         ESTABLISHED 1720/memcached      
tcp        0      0 127.0.0.1:42844         127.0.0.1:11210         ESTABLISHED 1663/moxi           
tcp        0      0 127.0.0.1:11210         127.0.0.1:42534         ESTABLISHED 1720/memcached      
tcp        0      0 127.0.0.1:42534         127.0.0.1:11210         ESTABLISHED 1663/moxi           
tcp        0      0 127.0.0.1:11210         127.0.0.1:42844         ESTABLISHED 1720/memcached      
tcp        0      0 127.0.0.1:46576         127.0.0.1:11210         ESTABLISHED 1663/moxi           
tcp6       0      0 :::11210                :::*                    LISTEN      1720/memcached

Hi,

Any Updates? Kindly help

Hi,

I tried installing couchbase server on AWS Market place which is of the version 2.3 and when i installed php sdk everything worked fine. But when I installed sever manually on a instance on google cloud manually I am getting the error (version 4.1). PHP client used was 2.2.2 in both cases.

Kindly help us identify the issue.

I am experiencing the same issue. However, I am running my PHP SDK on a separate machine from my Couchbase server. Is this allowed? I can telnet to my Couchbase server on ports 8091 and 11210 just fine, but cannot do so via the PHP SDK.

Could you post the logs? https://developer.couchbase.com/documentation/server/current/sdk/php/collecting-information-and-logging.html

Sure thing. Not sure which log level you prefer so I did one request at TRACE and another at DEBUG. Thanks for following-up.Archive.zip (4.5 KB)

but from logs:

[16-Jan-2017 19:49:58 UTC] [cb,INFO] (pcbc/bucket L:182) New lcb_t instance has been initialized. I=0x7fc42a6db810
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (confmon L:89 I:0) Preparing providers (this may be called multiple times)
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (confmon L:99 I:0) Provider FILE is DISABLED
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (confmon L:96 I:0) Provider CCCP is ENABLED
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (confmon L:96 I:0) Provider HTTP is ENABLED
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (confmon L:99 I:0) Provider MCRAW is DISABLED
[16-Jan-2017 19:49:58 UTC] [cb,INFO] (cccp L:126 I:0) Requesting connection to node localhost:11210 for CCCP configuration
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (lcbio_mgr L:416 I:0) <localhost:11210> (HE=0x7fc42ad4d6c0) Creating new connection because none are available in the pool
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (lcbio_mgr L:321 I:0) <localhost:11210> (HE=0x7fc42ad4d6c0) Starting connection on I=0x7fc42ad4db90
[16-Jan-2017 19:49:58 UTC] [cb,INFO] (connection L:450 I:0) <localhost:11210> (SOCK=0x7fc42ad4dc30) Starting. Timeout=2000000us
[16-Jan-2017 19:49:58 UTC] [cb,EROR] (connection L:127 I:0) <localhost:11210> (SOCK=0x7fc42ad4dc30) Failed: lcb_err=0x2c, os_errno=111
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (lcbio_mgr L:271 I:0) <localhost:11210> (HE=0x7fc42ad4d6c0) Received result for I=0x7fc42ad4db90,C=0; E=0x2c
[16-Jan-2017 19:49:58 UTC] [cb,EROR] (cccp L:142 I:0) <NOHOST:NOPORT> Got I/O Error=0x2c
[16-Jan-2017 19:49:58 UTC] [cb,INFO] (confmon L:202 I:0) Provider 'CCCP' failed
[16-Jan-2017 19:49:58 UTC] [cb,DEBG] (confmon L:236 I:0) Will try next provider in 0us
[16-Jan-2017 19:49:58 UTC] [cb,INFO] (connection L:450 I:0) <localhost:8091> (SOCK=0x7fc42ad4e2d0) Starting. Timeout=2000000us
[16-Jan-2017 19:49:58 UTC] [cb,EROR] (connection L:127 I:0) <localhost:8091> (SOCK=0x7fc42ad4e2d0) Failed: lcb_err=0x2c, os_errno=111
[16-Jan-2017 19:49:58 UTC] [cb,EROR] (htconfig L:334 I:0) Connection to REST API failed with code=0x2c (111)
[16-Jan-2017 19:49:58 UTC] [cb,INFO] (confmon L:202 I:0) Provider 'HTTP' failed
[16-Jan-2017 19:49:58 UTC] [cb,EROR] (bootstrap L:111 I:0) Failed to bootstrap client=0x7fc42a6db810. Code=0xa, Message=No more bootstrap providers remain

It clearly tries to connect to localhost:11210 and localhost:8091, are you sure you have specified correct address to CouchbaseCluster constructor?

Yes that concerned me, too. But I just confirmed and the host connection is most definitely:

new CouchbaseCluster('http://stage.arcpointgroup.com:8091')