MongoDB extension

144 views
Skip to first unread message

mark

unread,
Jul 2, 2016, 10:05:33 PM7/2/16
to Lucee
Does anyone know how to authenticate a connection? I think db.auth worked with the last version of the mongodb extension but does not seem
to work with current version 3.2, lucee error on db.auth function does not exist, it does work when added to a mongo: uri string but it connects and then
closes with each db call.

thanks,
Mark.

Sean Daniels

unread,
Jul 4, 2016, 9:17:40 AM7/4/16
to lu...@googlegroups.com
auth() was removed in favor of using the MongoDB connection string method of authentication.

I believe the syntax is something like this, but verify with the MongoDB Java driver docs to be sure.

db = MongoDBConnect("mongodb://user:password@localhost:27017/test”);
> --
> Win a ticket to dev.objective from Lucee via Twitter, see http://bit.ly/1UbTMWj for details, good luck and see you there...
> ---
> You received this message because you are subscribed to the Google Groups "Lucee" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
> To post to this group, send email to lu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/8b61539a-1a3e-4fee-9fdd-b850c80bba65%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

mark

unread,
Jul 4, 2016, 1:30:11 PM7/4/16
to Lucee
Thanks for the quick reply,

as mentioned in my previous post it is possible to connect with a mongo:uri string but you have to specify the database first,

db  = MongoDBConnect("testdb", "mongodb://user:password@localhost:27027");

if you do a dump

dump(var:db, expand:true);

it doesn't seem to reuse the connection,

2016-07-04T11:55:07.104-0500 I ACCESS   [conn120] Successfully authenticated as
principal public on admin
2016-07-04T11:55:09.991-0500 I NETWORK  [initandlisten] connection accepted from
 127.0.0.1:8498 #121 (121 connections now open)
2016-07-04T11:55:10.018-0500 I ACCESS   [conn121] Successfully authenticated as
principal user on admin
2016-07-04T11:55:10.019-0500 I NETWORK  [initandlisten] connection accepted from
 127.0.0.1:8499 #122 (122 connections now open)
2016-07-04T11:55:10.039-0500 I ACCESS   [conn122] Successfully authenticated as
principal user on admin
2016-07-04T11:55:50.372-0500 I NETWORK  [conn118] end connection 127.0.0.1:8495
(121 connections now open)
2016-07-04T11:56:07.059-0500 I NETWORK  [conn120] end connection 127.0.0.1:8497
(120 connections now open)
2016-07-04T11:56:09.990-0500 I NETWORK  [conn122] end connection 127.0.0.1:8499
(119 connections now open)

mark

unread,
Jul 5, 2016, 6:14:13 PM7/5/16
to Lucee
Hey Sean,
after digging a little deeper and testing the older driver it seems as though neither mongodb extensions create
a connection pool? Or is there something I'm missing.



On Saturday, July 2, 2016 at 9:05:33 PM UTC-5, mark wrote:

Lyle Karstensen

unread,
Jul 10, 2016, 11:37:44 AM7/10/16
to Lucee
Not sure if you are interested or what your need for extension is but I have a cfc that does mongo operations. It does not implement everything but you may find it useful as a start place. I use it in my sites and have never had an issue. I have not added authentication since my mongo servers are isolated locally and don't require it. but adding it should be simple enough.

Not sure if I am being helpful or muddying the waters, let me know if I can help.

Sean Daniels

unread,
Jul 10, 2016, 12:33:19 PM7/10/16
to lu...@googlegroups.com
> Hey Sean,
> after digging a little deeper and testing the older driver it seems as though neither mongodb extensions create
> a connection pool? Or is there something I'm missing.

Sorry, been on vacation. I do not believe the extension uses connection pooling like a traditional DB driver. When you call MongoDBConnect it creates a single MongoClient. It's up to you to persist this connection in your application.

application.mongo = MongoDBConnect(uri);


Message has been deleted

mark

unread,
Jul 10, 2016, 6:55:18 PM7/10/16
to Lucee
Ok nevermind,

it's kind of weird but when you do a db=MongoDBConnect("testdb","localhost", 27017); the connection pool seems to work fine 
but this will create a new connection on each call, db=MongoDBConnect("testdb", "mongodb://localhost:27017");,
did as you suggested and it works just dandy. application.mongo = MongoDBConnect("testdb", "mongodb://localhost:27017");


thanks for clearing that up Sean.

Sean Daniels

unread,
Jul 11, 2016, 8:51:50 AM7/11/16
to lu...@googlegroups.com
No problem Mark. I'll add something about this to the ReadMe in GitHub.
> --
> Win a ticket to dev.objective from Lucee via Twitter, see http://bit.ly/1UbTMWj for details, good luck and see you there...
> ---
> You received this message because you are subscribed to the Google Groups "Lucee" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to lucee+un...@googlegroups.com.
> To post to this group, send email to lu...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/lucee/2ab7566a-a62e-46e4-be14-209bb65e6ac4%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages