"Error: cannot perform operations on a shutdown bucket" when calling remote server

I have couchbase-server installed on a remote server.
When I try to access it with couchnode from the remote server itself, by launching node through ssh, it works.

When I try to access it by launching node on my local windows machine, I get the error :
Error: cannot perform operations on a shutdown bucket
at Bucket._maybeInvoke (C:\Users\mfresh\project\public_html\node_modules\couchbase\lib\bucket.js:855:11)
at Bucket.get (C:\Users\mfresh\project\public_html\node_modules\couchbase\lib\bucket.js:982:8)
at Object.getUser (C:/Users/mfresh/project/public_html/src/server/user/userUtils.js:156:12)
at C:/Users/mfresh/project/public_html/src/server/db/routes.js:119:19
at Layer.handle [as handle_request] (C:\Users\mfresh\project\public_html\node_modules\express\lib\router\layer.js:82:5)
at next (C:\Users\mfresh\project\public_html\node_modules\express\lib\router\route.js:110:13)
at Route.dispatch (C:\Users\mfresh\project\public_html\node_modules\express\lib\router\route.js:91:3)
at Layer.handle [as handle_request] (C:\Users\mfresh\project\public_html\node_modules\express\lib\router\layer.js:82:5)
at C:\Users\mfresh\project\public_html\node_modules\express\lib\router\index.js:267:22
at Function.proto.process_params (C:\Users\mfresh\project\public_html\node_modules\express\lib\router\index.js:321:12)
at next (C:\Users\mfresh\project\public_html\node_modules\express\lib\router\index.js:261:10)
at C:\Users\mfresh\project\public_html\node_modules\body-parser\lib\read.js:111:5
at done (C:\Users\mfresh\project\public_html\node_modules\body-parser\node_modules\raw-body\index.js:248:14)
at IncomingMessage.onEnd (C:\Users\mfresh\project\public_html\node_modules\body-parser\node_modules\raw-body\index.js:294:7)
at IncomingMessage.g (events.js:180:16)
at IncomingMessage.emit (events.js:92:17)

The difference in configuration between the local machine’s couchnode and the remote server’s couchnode is only:
On the remote server it accesses the couchbase server that is on the same machine:
var myCluster = new couchbase.Cluster(‘127.0.0.1:8091’);
On the local machine it accesses the couchbase server that is on the remote server:
var myCluster = new couchbase.Cluster(‘myServerIp:8091’);

Why is it not working on the local machine?

I notice that the headers are different, for example when I launch it on the remote server there is an “authorization” header that’s missing when I call from local.

hey @brett19 can you advise here please?

Hey @mfresh,

Can you try to capture the error event and see what it says?

var cluster = new couchbase.Cluster(...);
var bucket = cluster.openBucket(...);
bucket.on('error', function(err) {
  console.log('CONNECT ERROR:', err);
});

Cheers, Brett

From the local machine, the error displayed is : CONNECT ERROR: { [Error: failed to connect to bucket] code: 23 }

Hey @mfresh,

Are you sure you did not configure Couchbase server using a hostname which is only visible from outside your local machine?

Cheers, Brett

When I type “myserverip:8091” in Chrome’s address bar on the local machine, I can access the admin interface of couchbase-server.
So the server should be visible from the local machine.

Also I have a lot of minor page faults, I dont know if this is normal.

Also adding the request headers:

Request headers when starting couchnode on the remote server with ssh (works)
{ ‘x-real-ip’: ‘178.251.16.50’,
‘x-forwarded-for’: ‘178.251.16.50’,
host: ‘example.com’,
‘x-nginx-proxy’: ‘true’,
connection: ‘upgrade’,
‘content-length’: ‘46’,
authorization: ‘Basic ZnKhbmNlRoEwMDplenExNyM=’,
accept: ‘application/json’,
origin: ‘http://example.com’,
‘user-agent’: ‘Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/46.0.2484.0 Safari/537.36’,
‘content-type’: ‘application/json’,
referer: ‘http://example.com/’,
‘accept-encoding’: ‘gzip, deflate’,
‘accept-language’: ‘fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4’ }

Request headers when starting couchnode on the local machine (does not work)
{ ‘cache-control’: ‘no-cache’,
pragma: ‘no-cache’,
connection: ‘close’,
‘content-length’: ‘46’,
referer: ‘http://localhost:4000/’,
‘content-type’: ‘application/json; charset=UTF-8’,
‘accept-encoding’: ‘identity’,
‘accept-language’: ‘fr,fr-FR;q=0.8,en-US;q=0.5,en;q=0.3’,
accept: ‘application/json’,
‘user-agent’: ‘Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0’,
host: ‘localhost:3000’,
agent: ‘false’ }

Hey @mfresh,

Internally there are a lot of hostname pointers that are used to communicate with the cluster. If the hostname in the configuration of the Cluster is incorrect, it is possible that connections are failing internally. From what I can tell, it would appear this is your issue. You may wish to try and reinstall your cluster, this time without using any local-only names for the hostname.

Cheers, Brett

Are you talking about the cluster name in Settings / Cluster / Configure Cluster / Cluster Name ?
So far I have left it blank.

Also I see that below that there is an SSL certificate. Should I add this certificate on the local machine maybe?

Hey @mfresh,

The SSL certificate is only required when using TLS connections, which you likely are not (assuming you are using couchbase:// to connect). In terms of the cluster name, I’m actually talking about the per-node hostname specified when configuring the cluster for the first time (this is the only time you would see it).

Cheers, Brett

I just read the doc “Using hostnames”. It says “Couchbase Server stores the hostnames in a config file on the disk.” Which file would that be? I see a config file at /opt/couchbase/etc/couchbase/config but that file is blank.

Also, I see that the default hostname is “127.0.0.1”. If I understand what you are saying, that hostname only allows local access to the cluster, and I should replace it with the server IP ?

Hey @mfresh,

Essentially yes. However the hostname may be stored in multiple places and references through multiple nodes. It is far more reliable to simply reconfigure the node entirely rather than trying to modify those files manually.

Cheers, Brett

This evening I tried on a different computer, running ubuntu server 14.04, the exact same code that fails on the computer running windows 7.
It works, I can save to or load from couchbase on the remote server. So I don’t see how this could be a problem of configuration of couchbase server.

In fact a few days ago I think it also worked on the windows machine.

I’m git pushing and pulling between the windows machine and the ubuntu machine. Before the windows machine was pointing to the remote server, whereas the ubuntu machine had its own instance of couchbase-server installed locally.

The problem with the windows machine first appeared when during a pull I erased the configuration that had it point to the remote server, and made it point locally (as for the ubuntu machine). Then the problem stayed even though I re-changed the configuration on the windows machine to make it point to the remote server.

So maybe there is some sort of cache in couchnode that keeps the former, incorrect configuration?

Installed couchbase server locally on the windows machine, still wasn’t working.

Replaced
"var myCluster = new couchbase.Cluster(‘127.0.0.1:8091’);"
with
"var myCluster = new couchbase.Cluster(‘couchbase://localhost’);"
and now it works.
Seems like different configurations are needed on Windows vs Linux.