title: MongoDB Java Driver 4.1.1 how to configure timeout settings
body: <p>I am migrating an application from using MongoDB Java driver v. 3.6.4 to v. 4.1.1</p>
  <p>In 3.6.4 configuration is passed via MongoClientOptions</p>
  <pre><code>@Bean
      public MongoClientOptions mongoOptions() {
          return MongoClientOptions.builder()
                  .connectTimeout(...)
                  .serverSelectionTimeout(..)
                  .socketTimeout(...)
                  .build();
      } 
  </code></pre>
  <p>In 4.1.1 MongoClientOptions has been deprecated, and I am utilizing MongoClientSettings class
  <a href="http://mongodb.github.io/mongo-java-driver/4.1/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html" rel="noreferrer">http://mongodb.github.io/mongo-java-driver/4.1/apidocs/mongodb-driver-core/com/mongodb/MongoClientSettings.Builder.html</a></p>
  <pre><code>   @Bean
      public MongoClientSettings mongoOptions() {
          return MongoClientSettings.builder()
                  .applyToSocketSettings(builder -&gt;
                          builder.applySettings(builder()
                                  .connectTimeout(config.getConnectTimeout(), MILLISECONDS).build()))
                  .applyToClusterSettings(builder -&gt;
                          builder.serverSelectionTimeout(config.getServerSelectionTimeout(), MILLISECONDS).build())
                  .build();
  
      }
  </code></pre>
  <p>However I can't find setting to configure connectTimeout (apart from supplying connection string via applyConnectionString method.</p>