[JAVA-710] Support max connection idle time and max connection life time Created: 09/Dec/12  Updated: 06/Apr/23  Resolved: 26/Nov/13

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: 2.10.1
Fix Version/s: 2.12.0, 3.0.0

Type: New Feature Priority: Major - P3
Reporter: Syam Raj Assignee: Jeffrey Yemin
Resolution: Done Votes: 6
Labels: driver
Σ Remaining Estimate: Not Specified Remaining Estimate: Not Specified
Σ Time Spent: Not Specified Time Spent: Not Specified
Σ Original Estimate: Not Specified Original Estimate: Not Specified

Issue Links:
Depends
Duplicate
is duplicated by JAVA-779 Support enforcement of a max idle tim... Closed
Related
related to JAVA-424 Allow pool to shrink Closed
is related to JAVA-1113 Connections to failed primary replica... Closed
is related to JAVA-499 Add support for connection validation Closed
Sub-Tasks:
Key
Summary
Type
Status
Assignee
JAVA-1004 3.0: Support max connection idle time... Sub-task Closed Jeffrey Yemin  
JAVA-1005 2.12: Support max connection idle tim... Sub-task Closed Jeffrey Yemin  

 Description   

We are using the 2.10.1 version of the java driver and idle connections are not getting timed out. Please provide support of maxIdleTimeMS property in the java driver or let us know if there a reason this is not implemented.

http://docs.mongodb.org/manual/reference/connection-string/#maxIdleTimeMS

Implementation:

In MongoClientOptions, the property names are maxConnectionIdleTIme and maxConnectionLifeTime. In MongoClientURI, the query parameter names are maxIdleTimeMS and maxLifeTimeMS.



 Comments   
Comment by Jeffrey Yemin [ 27/Feb/14 ]

Hi Alexej,

URI support is available in the latest snapshot, available here, if you'd like to test that. I documented the query parameter names in the description.

Thanks,
Jeff

Comment by Jeffrey Yemin [ 27/Feb/14 ]

Hi Alexej,

No, you're not missing anything. Thanks for catching this. I neglected to add support in the URI for these options. I'm working on it today, but until then you can only test using MongoClientOptions.

Thanks,
Jeff

Comment by Alexej Kubarev [ 27/Feb/14 ]

Hi Jeff, was trying to configure the Connection Idle time via the URI options (as part of the uri string) and it seems that this is not supported still?
Tried both maxConnectionIdleTime and maxIdleTimeMS and getting warning about unsupported option.

This is pretty understandable as i cant find those options in the source.
Maybe Im missing something?

Comment by Alexej Kubarev [ 27/Feb/14 ]

Going to test this together with the JAVA-1117 on your latest snapshot

Comment by Jeffrey Yemin [ 27/Feb/14 ]

Hi there,

Interested parties can test the fix with 2.12.0-rc0, available either on github or Maven Central. Any takers?

Thanks,
Jeff

Comment by Jeffrey Yemin [ 26/Nov/13 ]

I just pushed the code to master and also pushed a snapshot to Sonatype: https://oss.sonatype.org/content/repositories/snapshots/org/mongodb/mongo-java-driver/2.12.0-SNAPSHOT/mongo-java-driver-2.12.0-20131126.005249-6.jar.

Please give it a try and let us know how it's working for you.

Comment by Eyllo [ 25/Nov/13 ]

Any ideas when this will hit trunk? We are desperate for using this as we have deployed inside Azure and are fighting to stay on the game.
Thanks!

Comment by Jeffrey Yemin [ 09/Aug/13 ]

Added maxConnectionIdleTime and maxConnectionLifeTime properties to MongoClientOptions.
Added maxIdleTimeMS and maxLifeTimeMS to MongoClientURI.

Comment by Jeffrey Yemin [ 12/Jul/13 ]

Actually, still need to expose these settings via MongoClient, so re-opening

Generated at Thu Feb 08 08:52:53 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.