connect-couchbase
connect-couchbase copied to clipboard
Existing Code not working with Couchbase 5.0
Hi All,
The code is not up to date for Couchbase version 5.0, As you all are aware that couchbase has changed the authentication code in latest version. So this code needs to be updated for latest version
While I agree it should probably be updated the module has no specific couchbase version dependency so it would have to test to see if authenticate was a valid method of the cluster object and if so call that with a provided username/password otherwise not... and then it'd have to confirm that username and password were provided or maybe default them to the bucket name but that seems terrible...
I think your best bet is to use the db
property and auth/open the bucket externally.
const couchbase = require('couchbase'); const ms = require('ms'); const session = require('express-session'); const store = require('connect-couchbase'); var bucket; var cluster = new couchbase.Cluster('couchbase://127.0.0.1?detailed_errcodes=1'); cluster.authenticate($USERNAME, $PASSWORD); bucket = cluster.openBucket($BUCKET); $LIFETIME), secure: $BOOL; as appropriate }, name: something that doesn't scream "I'm using express", resave: $BOOL; as appropriate, rolling: $BOOL; as appropriate, saveUninitialized: $BOOL; as appropriate, secret: $SECRET store: new Store({ db: bucket -OR- cluster.openBucket($BUCKET) $LIFETIME) / 1e3, prefix: as appropriate }).on('disconnect', function () { // how important is it to your app that the session store is available? }); });
It doesn't work anymore with the last npm couchbase module (2.6.0).
Could you add an error message or description of the behavior? Does simply holding back the couchbase module still work or is it something else that is causing it not to work?
FWIW I'm not the maintainer of this project -- nor do I care to be -- I just thought the previous bug was a bit disingenuous; at the time. It may very well be that the module does not work with the latest SDK. That would be unfortunate, but not unexpected as the couchbase SDK is very volatile and even their own things (ottoman for example) don't work with the latest version or you have to go to some lengths to get it to work. In theory there's an Ottoman 2 but no one knows where it is or when it will be released or if released whether it will be compatible with the current SDK... I love couchbase, but it's a mess.
Thank you, waffledonkey.
With the couchbase sdk 2.5.1, your above example works perfectly. With the 2.6.0 I get the "cannot perform operations on a shutdown bucket" error when I instance the store with the "new Store" line. It seems to be an authentication problem. I agree with you about the SDK volatility...
Thank you again for your answer.
Glad to hear it. I think it’s a race condition. openBucket should probably be wrapped in a promise and with an actual “resolve” and not the half of a callback it is currently but I suspect that would have knock on effects for when the session gets attached to the request object/is available... ☹️
Sent from my iPhone
On Oct 4, 2018, at 01:35, dalborgo [email protected] wrote:
Thank you, waffledonkey.
With the couchbase sdk 2.5.1, your above example works perfectly. With the 2.6.0 I get the "cannot perform operations on a shutdown bucket" error when I instance the store with the "new Store" line. It seems to be an authentication problem. I agree with you about the SDK volatility...
Thank you again for your answer.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
My fault. With the couchbase 2.6.0 dependency my previous couchbase user (a read only user admin) doesn't work anymore. Righlty, a read only admin can't perform operation (for example write a doc) on the bucket. With the 2.5.1 instead you can do that with it. Changing the user's permission everything works properly.
Hey @dalborgo have you tried with @2.6.2 or do you have an example of the code you used with 2.6? my previous implementation is no longer working and it doesn't appear to be related to credentials/role.
See the attachment server.zip
I use the bucket connect event otherwise I get a "shoutdown bucket error" when i set the store.
bucket.on('connect', () => { ... })
You're good people. :)
I see you wrapped the whole server start in the event emitter... interesting. In my case it seems to work fine if I define the Store outside of mounting the middleware (similar to what you did) and if I hack on the module to add authentication, update the openBucket method signature and stop trying to set connection and operation timeout (basically, all the existing pull requests).
If, however, I try to pass it an existing bucket instance using the db option it doesn't work, thus why I asked.
I think we need to get the pull requests merged or someone needs to fork/takeover this project. How do you like Ottoman? Have you looked at Lounge? (it's more Mongoose-like)
I did not know Lounge! It is very interesting and more updated than Ottoman. Thank you for the advice.