0 0

mongodb java driver问题-长时间不操作数据库,连接异常20

java长时间不进行mongodb数据库访问,会抛出如下异常.
nested exception is com.mongodb.MongoException$Network: Read operation to server
之后再次访问连接正常.
不知各位有没有碰到过类似问题.
谢谢解答
2013年8月21日 17:00

2个答案 按时间排序 按投票排序

0 0

调一下参数试试:

options.connectionsPerHost = 100;
options.maxWaitTime = 2000;
options.socketKeepAlive = true;
options.threadsAllowedToBlockForConnectionMultiplier = 50;

spring 配置:

<mongo:mongo host="${mongodb.server}" port="${mongodb.port}">
    <mongo:options  
      connections-per-host="${mongo.connectionsPerHost}"  
      threads-allowed-to-block-for-connection-    multiplier="${mongo.threadsAllowedToBlockForConnectionMultiplier}"  
         connect-timeout="${mongo.connectTimeout}"  
         max-wait-time="${mongo.maxWaitTime}"  
         auto-connect-retry="${mongo.autoConnectRetry}"  
         socket-keep-alive="${mongo.socketKeepAlive}"  
         socket-timeout="${mongo.socketTimeout}"     
/>

2013年8月22日 09:50
0 0

确保连接池的心跳比MONGODB的心跳低,这样mongodb就不会自动把非活动的连接给关闭了

2013年8月21日 17:06

相关推荐

Global site tag (gtag.js) - Google Analytics