Cant use the SDK

I installed the latest current PHP SDK version and no matter what script I use to connect to my cluster on localhost I can’t connect…I’m including the php error log and my php ini

#0 {main}
  thrown in /usr/share/nginx/couchbasesdk/create_document.php on line 4
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (pcbc/cluster L:46) Initialize Cluster. C=0x7f34f9e61000 connstr="couchbase://localhost"
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (pcbc/pool L:159) Rewrite connection string from "couchbase://localhost" to "couchbase://localhost/pets_app"
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (pcbc/pool L:53) New lcb_t instance has been initialized. I=0x14d5fa0
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (pcbc/pool L:56) Using authenticator. md5="3943d37ab2c01c821573a8d1661ada30". I=0x14d5fa0
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (confmon L:83 I:1) Preparing providers (this may be called multiple times)
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (confmon L:90 I:1) Provider CCCP is ENABLED
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (confmon L:90 I:1) Provider HTTP is ENABLED
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (cccp L:144 I:1) Requesting connection to node localhost:11210 for CCCP configuration
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (lcbio_mgr L:416 I:1) <localhost:11210> (HE=0x14d86b0) Creating new connection because none are available in the pool
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (connection L:458 I:1) <localhost:11210> (SOCK=0x14d8bd0) Starting. Timeout=2000000us
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (connection L:223 I:1) <localhost:11210> (SOCK=0x14d8bd0) Created new socket with FD=7
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (connection L:223 I:1) <localhost:11210> (SOCK=0x14d8bd0) Created new socket with FD=7
[29-Mar-2017 15:39:18 UTC] [cb,WARN] (lcbio L:103 I:1) FIXME: Unknown iops/os error code 13. Using NETWORK_ERROR
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (lcbio L:112 I:1) Translating errno=13, lcb=0x10 to NETWORK_ERROR
[29-Mar-2017 15:39:18 UTC] [cb,EROR] (connection L:141 I:1) <localhost:11210> (SOCK=0x14d8bd0) Failed to establish connection: LCB_NETWORK_ERROR (0x10), os errno=13
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (lcbio_mgr L:271 I:1) <localhost:11210> (HE=0x14d86b0) Received result for I=0x14d49f0,C=(nil); E=0x10
[29-Mar-2017 15:39:18 UTC] [cb,EROR] (cccp L:160 I:1) <NOHOST:NOPORT> Could not get configuration: LCB_NETWORK_ERROR (0x10)
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (confmon L:177 I:1) Provider 'CCCP' failed
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (confmon L:211 I:1) Will try next provider in 0us
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (connection L:458 I:1) <localhost:8091> (SOCK=0x14d7940) Starting. Timeout=2000000us
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (connection L:223 I:1) <localhost:8091> (SOCK=0x14d7940) Created new socket with FD=7
[29-Mar-2017 15:39:18 UTC] [cb,DEBG] (connection L:223 I:1) <localhost:8091> (SOCK=0x14d7940) Created new socket with FD=7
[29-Mar-2017 15:39:18 UTC] [cb,WARN] (lcbio L:103 I:1) FIXME: Unknown iops/os error code 13. Using NETWORK_ERROR
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (lcbio L:112 I:1) Translating errno=13, lcb=0x10 to NETWORK_ERROR
[29-Mar-2017 15:39:18 UTC] [cb,EROR] (connection L:141 I:1) <localhost:8091> (SOCK=0x14d7940) Failed to establish connection: LCB_NETWORK_ERROR (0x10), os errno=13
[29-Mar-2017 15:39:18 UTC] [cb,EROR] (htconfig L:295 I:1) Connection to REST API failed with LCB_NETWORK_ERROR (0x10) (os errno = 13)
[29-Mar-2017 15:39:18 UTC] [cb,INFO] (confmon L:177 I:1) Provider 'HTTP' failed
[29-Mar-2017 15:39:18 UTC] [cb,EROR] (bootstrap L:129 I:1) Failed to bootstrap client=0x14d5fa0. Error=LCB_NETWORK_ERROR (0x10), Message=No more bootstrap providers remain
[29-Mar-2017 15:39:18 UTC] [cb,EROR] (pcbc/pool L:92) Failed to bootstrap LCB connection: LCB_NETWORK_ERROR: Generic network failure. Enable detailed error codes (via LCB_CNTL_DETAILE$
[29-Mar-2017 15:39:18 UTC] PHP Fatal error:  Uncaught Couchbase\Exception: LCB_NETWORK_ERROR: Generic network failure. Enable detailed error codes (via LCB_CNTL_DETAILED_ERRCODES, or $
Stack trace:
#0 /usr/share/nginx/couchbasesdk/Authenticator.php(9): Couchbase\Cluster->openBucket('pets_app')
#1 {main}
  thrown in /usr/share/nginx/couchbasesdk/Authenticator.php on line 9

php.ini

couchbase

couchbase support	enabled
extension version	2.3.0
libcouchbase runtime version	2.7.3 (git: 095afbb1a83bfef8def6d50bf50ee494b6c3c67f)
libcouchbase headers version	2.7.3 (git: 095afbb1a83bfef8def6d50bf50ee494b6c3c67f)
igbinary transcoder	enabled
zlib compressor	enabled

Authenticator.php code

<?php
$authenticator = new \Couchbase\ClassicAuthenticator();
$authenticator->cluster('Administrator', 'node_password');
$authenticator->bucket('bucket_name', 'bucket_password');

$cluster = new \Couchbase\Cluster("couchbase://localhost");
$cluster->authenticate($authenticator);

$cluster->openBucket('bucket_name'); // successfully opens connection
$cluster->manager()->createBucket('hello'); // automatically use admin credentials

What OS are you using? does it work if you run it outside nginx with the same settings?

This is interesting, what is your environment?

Could you try our SDK doctor to get more details about your setup, and post its output here?

sdk-doctor diagnose couchbase://localhost/bucket_name

also check your SELinux rules, and make sure that nginx worker process allowed to open sockets, because code 13 means permission denied.

For example:

setenforce Permissive

thank you its working now but cant store and read documents though I can connect. I will go through the docs and see what can I find.

About the sdk-doctor-linux i keep getting permission denied even if i run it in sudo. my environment is centos 6

have you tried to put SELinux into permissive mode? It might block access even for root

sudo setenforce Permissive 

that made the connection work but what I’m getting is

[29-Mar-2017 16:30:37 UTC] [cb,EROR] (negotiation L:131 I:1) <10.128.0.3:11210> (SASLREQ=0x14f40b0) Error: 0x2, SASL Step Failed
[29-Mar-2017 16:30:37 UTC] [cb,EROR] (server L:467 I:1) <NOHOST:NOPORT> (SRV=0x14e79e0,IX=0) Connection attempt failed. Received LCB_AUTH_ERROR (0x02) from libcouchbase, received 0 fr$
[29-Mar-2017 16:30:37 UTC] [cb,DEBG] (retryq L:312 I:1) Adding PKT=0x14f44d0 to retry queue. Try count=18
[29-Mar-2017 16:30:37 UTC] [cb,INFO] (bootstrap L:164 I:1) Not requesting a config refresh because of throttling parameters. Next refresh possible in 7682ms or 82 errors. See LCB_CNTL$
[29-Mar-2017 16:30:37 UTC] [cb,DEBG] (ioctx L:151 I:1) <10.128.0.3:11210> (CTX=0x14f4250,sasl) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
[29-Mar-2017 16:30:37 UTC] [cb,WARN] (retryq L:142 I:1) Failing command (seq=0) from retry queue with error code 0x2
[29-Mar-2017 16:30:37 UTC] PHP Fatal error:  Uncaught Couchbase\Exception: LCB_AUTH_ERROR: Authentication failed. You may have provided an invalid username/password combination in /us$
Stack trace:
#0 /usr/share/nginx/couchbasesdk/Authenticator.php(12): Couchbase\Bucket->upsert('u:king_arthur', Array)
#1 {main}
  thrown in /usr/share/nginx/couchbasesdk/Authenticator.php on line 12
[29-Mar-2017 16:30:37 UTC] [cb,DEBG] (pcbc/pool L:211) cachedel: type=0, connstr=couchbase://localhost/the_app, bucketname=the_app, auth_hash=fe5be6c47777778889vcdxdzsz213esddewqf6b164ea4d1a47d2bfd2, lcb=0$

could you post the server version, and re-run it with TRACE log level?

Could you also try to pass bucket password directly to the openBucket?

<?php
$cluster = new \Couchbase\Cluster("couchbase://localhost");
$cluster->openBucket('bucket_name', 'bucket_password');

couchbase server 4.6.0

my log after running

<?php
$cluster = new \Couchbase\Cluster("couchbase://localhost");
$cluster->openBucket('bucket_name', 'bucket_password');

is

[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (pcbc/cluster L:46) Initialize Cluster. C=0x7f34f9e61000 connstr="couchbase://localhost"
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (pcbc/pool L:159) Rewrite connection string from "couchbase://localhost" to "couchbase://localhost/the_app"
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (pcbc/pool L:53) New lcb_t instance has been initialized. I=0x14f4300
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (pcbc/pool L:56) Using authenticator. md5="ec83fcd4f3e6a3f4c10c6abae4b57b17". I=0x14f4300
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (confmon L:83 I:3) Preparing providers (this may be called multiple times)
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (confmon L:90 I:3) Provider CCCP is ENABLED
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (confmon L:90 I:3) Provider HTTP is ENABLED
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (cccp L:144 I:3) Requesting connection to node localhost:11210 for CCCP configuration
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (lcbio_mgr L:416 I:3) <localhost:11210> (HE=0x14f6f70) Creating new connection because none are available in the pool
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (connection L:458 I:3) <localhost:11210> (SOCK=0x14f7780) Starting. Timeout=2000000us
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (connection L:223 I:3) <localhost:11210> (SOCK=0x14f7780) Created new socket with FD=11
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (connection L:130 I:3) <localhost:11210> (SOCK=0x14f7780) Connected established
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (connection L:137 I:3) <localhost:11210> (SOCK=0x14f7780) Successfuly set TCP_NODELAY
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (lcbio_mgr L:271 I:3) <localhost:11210> (HE=0x14f6f70) Received result for I=0x14f7520,C=0x14f7780; E=0x0
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (lcbio_mgr L:223 I:3) <localhost:11210> (HE=0x14f6f70) Assigning R=0x14f6f20 SOCKET=0x14f7780
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (ioctx L:101 I:3) <localhost:11210> (CTX=0x14f8160,unknown) Pairing with SOCK=0x14f7780
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (negotiation L:392 I:3) <localhost:11210> (SASLREQ=0x14f7fc0) Server supports feature: 0x3 (TCP NODELAY)
[29-Mar-2017 16:46:25 UTC] [cb,WARN] (negotiation L:514 I:3) <localhost:11210> (SASLREQ=0x14f7fc0) SASL auth failed with STATUS=0x20
[29-Mar-2017 16:46:25 UTC] [cb,EROR] (negotiation L:131 I:3) <localhost:11210> (SASLREQ=0x14f7fc0) Error: 0x2, SASL Step Failed
[29-Mar-2017 16:46:25 UTC] [cb,EROR] (cccp L:160 I:3) <NOHOST:NOPORT> Could not get configuration: LCB_AUTH_ERROR (0x02)
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (confmon L:177 I:3) Provider 'CCCP' failed
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (confmon L:211 I:3) Will try next provider in 0us
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (ioctx L:151 I:3) <localhost:11210> (CTX=0x14f8160,sasl) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (connection L:458 I:3) <localhost:8091> (SOCK=0x14f7780) Starting. Timeout=2000000us
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (connection L:223 I:3) <localhost:8091> (SOCK=0x14f7780) Created new socket with FD=11
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (connection L:130 I:3) <localhost:8091> (SOCK=0x14f7780) Connected established
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (connection L:137 I:3) <localhost:8091> (SOCK=0x14f7780) Successfuly set TCP_NODELAY
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (htconfig L:300 I:3) Successfuly connected to REST API localhost:8091
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (ioctx L:101 I:3) <localhost:8091> (CTX=0x14f7570,unknown) Pairing with SOCK=0x14f7780
[29-Mar-2017 16:46:25 UTC] [cb,EROR] (htconfig L:141 I:3) <localhost:8091> Got non-success HTTP status code 401
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (ioctx L:151 I:3) <localhost:8091> (CTX=0x14f7570,bc_http) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (connection L:458 I:3) <localhost:8091> (SOCK=0x14f7780) Starting. Timeout=2000000us
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (connection L:223 I:3) <localhost:8091> (SOCK=0x14f7780) Created new socket with FD=11
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (connection L:130 I:3) <localhost:8091> (SOCK=0x14f7780) Connected established
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (connection L:137 I:3) <localhost:8091> (SOCK=0x14f7780) Successfuly set TCP_NODELAY
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (htconfig L:300 I:3) Successfuly connected to REST API localhost:8091
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (ioctx L:101 I:3) <localhost:8091> (CTX=0x14f7570,unknown) Pairing with SOCK=0x14f7780
[29-Mar-2017 16:46:25 UTC] [cb,EROR] (htconfig L:141 I:3) <localhost:8091> Got non-success HTTP status code 401
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (ioctx L:151 I:3) <localhost:8091> (CTX=0x14f7570,bc_http) Destroying context. Pending Writes=0, Entered=true, Socket Refcount=1
[29-Mar-2017 16:46:25 UTC] [cb,INFO] (confmon L:177 I:3) Provider 'HTTP' failed
[29-Mar-2017 16:46:25 UTC] [cb,EROR] (bootstrap L:129 I:3) Failed to bootstrap client=0x14f4300. Error=LCB_AUTH_ERROR (0x02), Message=No more bootstrap providers remain
[29-Mar-2017 16:46:25 UTC] [cb,EROR] (pcbc/pool L:92) Failed to bootstrap LCB connection: LCB_AUTH_ERROR: Authentication failed. You may have provided an invalid username/password com$
[29-Mar-2017 16:46:25 UTC] PHP Fatal error:  Uncaught Couchbase\Exception: LCB_AUTH_ERROR: Authentication failed. You may have provided an invalid username/password combination in /us$
Stack trace:
#0 /usr/share/nginx/couchbasesdk/Authenticator.php(25): Couchbase\Cluster->openBucket('the_app', 'bucket_password')
#1 {main}
  thrown in /usr/share/nginx/couchbasesdk/Authenticator.php on line 25
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (pcbc/pool L:288) cachedtor: ptr=0x14e8860
[29-Mar-2017 16:46:25 UTC] [cb,DEBG] (ioctx L:151 I:2) <localhost:8091> (CTX=0x14d7310,bc_http) Destroying context. Pending Writes=0, Entered=false, Socket Refcount=1

you can use github-style code snippets like this

```php
<?php
// some php code
```

or just use CTRL+SHIFT+C to insert four spaces before selected text to make it preformatted.

Are you using correct bucket password?

sorry and thanks its working now…

<?php
$cluster = new \Couchbase\Cluster("couchbase://localhost");
$cluster->openBucket('bucket_name', 'bucket_password');

instead of my old code worked…
Thanks avsej

so the only difference was in Authenticator? You have probably hit PCBC-471, which will be fixed in next release 2.3.1 (which is going to be published on next week)