Skip to content

Commit

Permalink
ATS-15 added socket timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
madness-inc committed Aug 16, 2019
1 parent 6612f3c commit 232cc3a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/appng/tomcat/session/mongo/MongoStore.java
Expand Up @@ -181,6 +181,9 @@ public class MongoStore extends StoreBase {
/** Should a TTL index be used to expire sessions ? */
private boolean useTTLIndex = false;

/** The socket timeout when connecting to a MongoDB server */
private int socketTimeout = 10000;

/**
* Retrieve the unique Context name for this Manager. This will be used to separate out sessions from different
* application Contexts.
Expand Down Expand Up @@ -489,7 +492,7 @@ private void getConnection() throws LifecycleException {
MongoClientOptions options = MongoClientOptions.builder().connectTimeout(connectionTimeoutMs)
.maxWaitTime(connectionWaitTimeoutMs).connectionsPerHost(maxPoolSize).writeConcern(writeConcern)
.readPreference(readPreference).readConcern(readConcern).requiredReplicaSetName(replicaSet)
.build();
.socketTimeout(socketTimeout).build();

List<ServerAddress> hosts = new ArrayList<ServerAddress>();
for (String dbHost : this.hosts.split(",")) {
Expand Down

0 comments on commit 232cc3a

Please sign in to comment.