PHP : connection to server is erroring

try with

new CouchbaseCluster('couchbase://stage.arcpoint.group.com')

Notice my app code does this:

$cluster = new CouchbaseCluster('http://stage.arcpointgroup.com:8091'); $this->Couchbase = $cluster->openBucket('myBucket', '<password>'); print_r($cluster); die();

And I get this as the output (notice the object’s bucket name does not match the one I tried to open):

CouchbaseCluster Object (
[_manager:CouchbaseCluster:private] => 
[_dsn:CouchbaseCluster:private] => Array
    (
        [scheme] => http
        [hosts] => Array
            (
                [0] => Array
                    (
                        [0] => stage.arcpointgroup.com
                        [1] => 8091
                    )

            )

        [bucket] => default
        [options] => Array
            (
            )

    )

[authenticator:CouchbaseCluster:private] => )

That’s not working either (500 in the browser). Also, I assume you meant couchbase://stage.arcpointgroup.com (there’s no dot between “point” and “group”).

Side question that might be related… does the default bucket need to be installed? Because I did not set that up when I instantiated my server.

You don’t need to have the default bucket, but you do need to have the bucket you’re trying to connect to defined.

We have a small utility that we’ve written for testing connectivity in situations like this. It’s not ready for wide use yet, but I’m wondering, can you run it with the same connection string you’re using in the PHP client and see if it identifies any problems @kevin?

The tool is called SDK Doctor, and there should be a binary for your platform. The output should be easy to interpret, but if you have questions please post it to a gist/pastebin and then point @brett19 and I to it.

you should put it into PHP code, not into the browser. And also try the doctor binary, it would help to diagnose the problem.

Just ran:

> sdk-doctor-linux diagnose couchbase://stage.arcpointgroup.com/arc

Received the following output:
http://pastebin.com/iEf6x5nA

  • Please note I edited this paste because I had my firewall on when I ran the diagnostic tool the first time. This last paste was run while the firewall was turned off. Also, the bucket “arc” does exist and has data in it.

Ok a little more info now. I’ve managed to get the SDK Doctor to connect successfully to my bucket (just needed to supply credentials properly):

http://pastebin.com/7ZiKNySn

And I have a PHP script that I can run from the command line that is also working.

The same exact code within my PHP application, however, still does not work:

LCB_ECONNREFUSED: The remote host refused the connection. Is the service up? Error: An Internal Error Has Occurred.

So there must be an issue with my PHP configuration. See attached image for what my phpinfo() looks like for Couchbase (libcouchbase seems to be OK).

Any ideas? I appreciate all the quick and very helpful responses so far!

To verify no trouble at the libcouchbase layer, you could use something like cbc-get, which would use lcb directly without the PHP extension. I’m slightly stumped as to what would prevent the connection though.

If this were windows, I’d think of application level firewalling-- where Windows security extensions sometimes block apps from connecting to particular ports. Your sdk-doctor output indicates it’s linux.

When you say “PHP application”, do you mean running under php-fpm, apache? I think to diagnose the next level I’d do one of two things. One is use strace on the process to look at attempted connections, so you can see the syscall return to the process. Another one that may be easier is look at a tcpdump of Couchbase ports (or use wireshark-- it understands Couchbase’s protocols).

Unfortunately, I don’t think we can diagnose this any further with logging at the SDK, unless @mnunberg or @brett19 have an idea. When our code gets connection refused from the OS, I don’t think it’ll indicate why.

Yes. Calling the PHP code via the browser (thus invoking the Apache server) gives me the error I posted earlier.

Where would I find cbc-get?

Can you provide specifics? Apache2 may be most common, but there are options even there. Maybe that’ll trigger a thought on the cause.

On the cbc tools, they are installed as part of the ‘bin’ package, so if you install that per the instructions, you should have the cbc binary on your machine. The docs also have an overview on how to use cbc.

Thank you very much, ingenthr for your thorough assistance with this issue. It turned out to be an application-specific issue on my end with how I was handling the CB connection within the app’s data layer. I’m still trying to work out why exactly, but since it’s app specific there’s no need to trouble you guys with it anymore. I can confirm that my PHP SDK is working for me correctly both via command line and via Apache server as PHP-FPM.

1 Like

Glad to hear it’s working now!