目前使用 node.js (Native MongoDB) 驱动程序使用 Mongodb,我知道可以设置池连接计数,但无论观察到相同的行为。
有问题的代码:
(function init(){
db.connect("mongodb://localhost/test",function(err, database){
});
})();
这是来自服务器的日志:
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58663 #6
(1 connection now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58664 #7
(2 connections now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58665 #8
(3 connections now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58666 #9
(4 connections now open)
Thu Dec 06 20:19:32 [initandlisten] connection accepted from 127.0.0.1:58667 #10
(5 connections now open)
Thu Dec 06 20:19:36 [conn9] end connection 127.0.0.1:58666 (4 connections now op
en)
Thu Dec 06 20:19:36 [conn10] end connection 127.0.0.1:58667 (4 connections now o
pen)
Thu Dec 06 20:19:36 [conn8] end connection 127.0.0.1:58665 (4 connections now op
en)
Thu Dec 06 20:19:36 [conn6] end connection 127.0.0.1:58663 (4 connections now op
en)
Thu Dec 06 20:19:36 [conn7] end connection 127.0.0.1:58664 (4 connections now op
en)
连接显然正在关闭,但即使连接正确增加,当前打开的连接计数也不会减少。预期行为?
PS。请不要使用 mongodb 的 nodejs 包装器来回答。