Has anyone tried to use MongoDB Atlas Database as a service (https://www.mongodb.com) with Vertx?
I've tried to connect but I keep getting the following error:
INFO: Exception in monitor thread while connecting to server socie-shard-00-01-zeymc.mongodb.net:27017
com.mongodb.MongoSocketReadException: Prematurely reached end of stream
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:215)
at com.mongodb.connection.AsynchronousSocketChannelStream$BasicCompletionHandler.completed(AsynchronousSocketChannelStream.java:201)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:281)
at sun.nio.ch.WindowsAsynchronousSocketChannelImpl$ReadTask.completed(WindowsAsynchronousSocketChannelImpl.java:579)
at sun.nio.ch.Iocp$EventHandlerTask.run(Iocp.java:397)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
I used the following:
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-mongo-client</artifactId>
<version>3.5.0</version>
</dependency>
Than I tried to used their Java Mongo driver:
<dependency>
<groupId>org.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.6.0</version>
</dependency>
This works. Only this takes a big rewrite on all my queries. And I'm not sure if this is a good driver in combination with Vertx.
Does anyone know how to fix the error above or does anyone know if it's safe to use the org.mongodb java driver.
Many thanks in advance!
My solution
Thanks to Daniel, I managed to get it working with the vertx-mongo-client!
I added to my Json config
config.put("ssl", true);
And I added the following line before creating the MongoClient.
System.setProperty("org.mongodb.async.type", "netty");