I've been getting this error for weeks:
INFO: Closed connection [connectionId{localValue:820}] to 127.0.0.1:27017 because there was a socket exception raised by this connection.
Exception in thread "main" com.mongodb.MongoSocketReadException: Prematurely reached end of stream
at com.mongodb.connection.SocketStream.read(SocketStream.java:88)
at com.mongodb.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:492)
at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:222)
at com.mongodb.connection.CommandHelper.receiveReply(CommandHelper.java:134)
at com.mongodb.connection.CommandHelper.receiveCommandResult(CommandHelper.java:121)
at com.mongodb.connection.CommandHelper.executeCommand(CommandHelper.java:32)
at com.mongodb.connection.InternalStreamConnectionInitializer.initializeConnectionDescription(InternalStreamConnectionInitializer.java:83)
at com.mongodb.connection.InternalStreamConnectionInitializer.initialize(InternalStreamConnectionInitializer.java:43)
at com.mongodb.connection.InternalStreamConnection.open(InternalStreamConnection.java:116)
at com.mongodb.connection.UsageTrackingInternalConnection.open(UsageTrackingInternalConnection.java:49)
at com.mongodb.connection.DefaultConnectionPool$PooledConnection.open(DefaultConnectionPool.java:384)
at com.mongodb.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:101)
at com.mongodb.connection.DefaultConnectionPool.get(DefaultConnectionPool.java:87)
at com.mongodb.connection.DefaultServer.getConnection(DefaultServer.java:86)
at com.mongodb.binding.ClusterBinding$ClusterBindingConnectionSource.getConnection(ClusterBinding.java:86)
at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:239)
at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:214)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:483)
at com.mongodb.operation.FindOperation.execute(FindOperation.java:80)
at com.mongodb.Mongo.execute(Mongo.java:818)
at com.mongodb.Mongo$2.execute(Mongo.java:805)
at com.mongodb.OperationIterable.iterator(OperationIterable.java:47)
at com.mongodb.OperationIterable.forEach(OperationIterable.java:70)
at com.mongodb.FindIterableImpl.forEach(FindIterableImpl.java:158)
I followed the directions given by the answer to this question but nothing has changed. I cannot seem to decipher the MongoDB Java documentation well enough to figure out what can be done (spent countless hours doing so) since Mongo is constantly changing its standards.
What other options can I change to fix this problem? A code example that includes the Mongo Client creation and the options builder from start to finish would be really helpful.
The jar is deployed on a Ubuntu Amazon EC2 instance.