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
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.
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
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.
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
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.
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.