| Hi Davide! I was investigating a little bit more a I believe I found the problem. Finally I was able to make connection from my own MYCustomMongoDBDatastoreProvider (that you suggested me) only with make a connection with MongoClientOptions option sslEnabled(true), to do this I should create MongoClient and pass to it all options and configs like this:
ServerAddress seed1 = new ServerAddress("cluster0-clustername-shard-00-00-raa4n.mongodb.net", 27017);
ServerAddress seed2 = new ServerAddress("cluster0-clustername-shard-00-01-raa4n.mongodb.net", 27017);
ServerAddress seed3 = new ServerAddress("cluster0-clustername-shard-00-02-raa4n.mongodb.net", 27017);
List<ServerAddress> seedList = new ArrayList<ServerAddress>();
seedList.add(seed1);
seedList.add(seed2);
seedList.add(seed3);
List<MongoCredential> credentials = new ArrayList<MongoCredential>();
credentials.add(MongoCredential.createScramSha1Credential("atlas-user-name", "admin", "atlas-user-password".toCharArray()));
MongoClientOptions options = MongoClientOptions.builder()
.requiredReplicaSetName("Cluster0-clustername-shard-0").socketTimeout(30000)
.connectionsPerHost(1).sslEnabled(true).build();
return new MongoClient(seedList, credentials, options);
So without sslEnabled(true) I had the same error as before, but with it works fine. And I also found this issue https://github.com/metabase/metabase/issues/6678 where people had the same problems and as I was able to understand, they spoke about SSL problem too. In fact here https://docs.atlas.mongodb.com/driver-connection/ - "Connect via Driver" there is Prerequisites:
TLS/SSL
Clients must have support for TLS/SSL to connect to an Atlas cluster.
Clients must have support for the SNI TLS extension to connect to an Atlas M0 Free Tier or M2/M5 shared starter cluster. To verify that your driver supports the SNI TLS extension, refer to the Driver Compatibility matrix for your driver. Drivers which are compatible with MongoDB version 3.4 and up support the SNI TLS extension
I can't do objective conclusions, but may be this error is throws by lack of implementation SSL. |