Connection to couchbase failing to handle GET requests

When running the following code inside my app.js, connecting to Couchbase server running on Amazon EC2, i get the following error

{ [CouchbaseError: Operation not supported] message: ‘Operation not supported’, code: 19 }

This error also occurs when i try to run a GET command

var express = require("express");
var bodyParser = require("body-parser");
var couchbase = require("couchbase");
var ottoman = require("ottoman");

// Setup the framework
var app = express();

// Setup body parser to handle JSON requests
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));

// Setup connection
var cluster = new couchbase.Cluster("couchbase://my-amazon-instance.compute-1.amazonaws.com");
var bucket = cluster.openBucket("example",function(err){
    if(err){
        console.log("Can't open bucket");
        throw err;
    }
    else {
        console.log("Successfully opened bucket");
    }
});
// Prevent timing out
bucket.operationTimeout = 8000;

// This exposes bucket to other files in the project
module.exports.bucket = bucket;

// Include routes in bootstrapping
// Parse the initialize framework object (app)
var routes = require("./routes.js")(app);

// Tell Ottoman to use our buckets
ottoman.bucket = bucket;

// Ensure that ottoman uses its own indexes
ottoman.ensureIndices(function(error){
	if(error){
		console.log(error)
	}

	var server = app.listen(3000, function(){
		console.log("Listening on port %s...", server.address().port);
	})
})

Please help

Hi @aygdeveloper,

At what point in that Node example does the error occur? That might narrow down what operation the error message is referring to.

@matthew.groves just before the server starts at this line:
if(error){
console.log(error)
}
var server = app.listen(3000, function(){
console.log(“Listening on port %s…”, server.address().port);
})

Regards

Munya

Thanks @aygdeveloper,

I could be wrong, but my guess is that the error has something to do with ottoman. I will tag @brett19 and @nraboy, maybe they can help.

@matthew.groves thank alot.

The weird thing is, it only does so when i deploy it to AWS EC2 Instance but i dont get it on my local machine.

I am also not sure why my GET requests are not working.

I do appreciate the prompt response.

1 Like

@aygdeveloper,

Ah, well in that case, I imagine that it’s probably not related to the SDK. Maybe there are port(s) on the AWS instance that aren’t exposed.

@matthew.groves i have opened all the ports on my AWS instance but i am getting the same error.

POST are working but not GET.

Very confusing

Hey @aygdeveloper,

Can you confirm what version of Couchbase Server you are running, along with the cluster topology (how many servers, which services are enabled on each, for instance, are you sure the N1QL service is enabled on your cluster?). The main reason you would get Operation Not Supported is if you attempt to perform an operation which cannot be completed by the underlying libcouchbase library, a few examples of cases which might cause this:

  • Attempting to use SSL without a SSL-enabled libcouchbase (the bundled libcouchbase does not support it due to Node.js compatibility reasons).
  • Attempting to use N1QL without any N1QL services in your cluster.
  • Attempting to use a newer Node.js SDK with an older install of libcouchbase (via --couchbase-root), this fails since the Node.js SDK might internally use APIs which are not available in an older libcouchbase.
  • Attempting to use Couchbase operations on a Memcached bucket (this is less likely since your example code shouldn’t be performing any non-http operations).

Cheers, Brett

@brett19 , I am using:

Couchbase Server & Couchbase Sync Gateway Community Edition version 2.5.2 + 1.1.0 on aws
https://aws.amazon.com/marketplace/fulfillment?productId=c5a30d60-7d0d-48cf-a6a5-1402220ad8a1

In response to your questions:

Attempting to use SSL without a SSL-enabled libcouchbase (the bundled libcouchbase does not support it due to Node.js compatibility reasons). - The connect is not SSL

Attempting to use N1QL without any N1QL services in your cluster. - I am not doing this as far as i know

Attempting to use a newer Node.js SDK with an older install of libcouchbase (via --couchbase-root), this fails since the Node.js SDK might internally use APIs which are not available in an older libcouchbase. - What version of Node is compatible with the Sync gateway version 2.5.5 + 1.1.0 ?
Should i rather use this one:
https://aws.amazon.com/marketplace/pp/B013XDNYRG#

Attempting to use Couchbase operations on a Memcached bucket (this is less likely since your example code shouldn’t be performing any non-http operations). - The bucket is not memcached

FYI: The error get thrown first when i do this:

ottoman.ensureIndices(function(error){
	if(error){
		console.log(error)
	}
   }

I am currently running node v4.2.1

Thank you.

Regards

Hey!

Looks like the likely problem is the fact that you are using Couchbase Server 2.5.2. Ottoman internally attempts to create a N1QL primary index to support generic finds (the ability to arbitrarily search model properties). Unfortunately due to an oversight it does this indiscriminately without any regard for the fact that you do not have N1QL available. I will look into a solution for this.

Cheers, Brett

Note that Couchbase Server 2.5 is end of life. You may want to look to upgrade the stack.

@brett19, Thanks alot for the response, i couldn’t understand what was going on as i am running 4.6 enterprise edition on my local. Please keep me posted on the workaround.

@ingenthr I have upgraded my couchbase server to 4.0

https://aws.amazon.com/marketplace/pp/B016CM4KP0?qid=1482882254608&sr=0-5&ref_=srh_res_product_title

I am no longer getting the error 19

But i am now getting a timeout error, when creating the indexes

Error: An unknown N1QL error occured. This is usually related to an out-of-memory condition.

Working with couchbase has been a relatively frustrating experience i must say. :sweat:

Glad we’re moving you forward @aygdeveloper. I don’t quite know how, but you ended up on a very old AMI there.

Regarding the “unknown N1QL error”, it appears that there is a problem with ports in that AMI. I found this in another forums thread:

Maybe that will correct your problem as well?

Thanks alot @ingenthr opening port 8093 fixed my problem and everything seems to be working perfectly now!!! :grin:

Well, part of the reason i could have ended up with such an old version is because it shipped with sync gateway and since i am no server admin or couchbase expert, i opted to install that one to my own disadvantage but i am glad because i have learnt alot in the process thanks to the awesome support from you guys here.

@ingenthr @brett19 would you be able to point me to resources that can guide me on how to install sync gateway on an AWS EC2 instance, either in this community or externally.

Thanks again for all the help.

Highly appreciated!!!

1 Like

I think the best jumping off point for Sync Gateway installation is in the docs. @hod.greeley may be able to give you some other pointers or you can probably ask a bit more in that forums category.

@aygdeveloper there should be a newer AMI with both Sync Gateway and CB Server version 4.+ available.

Sync Gateway is very easy to install by itself anyway. I have a blog post that may help: https://blog.couchbase.com/2016/december/installing-sync-gateway-alternate-linux-distributions

Sync Gateway uses ports 4984 and 4985 by default. You can configure this. Just pointing that out so you open the right ports. 4985 is the admin port, so you may not want that open to the world.

Let us know what other questions you have. Also tagging @traun who is the AMI expert. If you have more questions on mobile (Couchbase Lite and Sync Gateway), better to post under the mobile category.

@hod.greeley thanks alot for the information. I have since installed the newer AMI with Sync Gateway and CB Server 4+ and i am no longer experiencing the issues i have been facing.

I do have additional Couchbase Lite and sync gateway questions which i will post in the mobile category as advised.

@traun once i install the AMI, i remote into the instance via ssh and run:
sudo netstat -nlp | grep :4984

I can see that my sync gateway is running on port 4984 as i get the response:

tcp        0      0 :::4984   :::*   LISTEN      2356/sync_gateway  

My questions are:

  1. How do i monitor the incoming connections and activity on the sync gateway via the browser ?
  2. I have read that 4985 is the “Admin” port, how do i access this either via the browser or otherwise?

Thanks again to the entire couchbase team for the excellent support your help.