title: Mongodb: `com.mongodb.MongoSocketReadException: Prematurely reached end of stream` with morphia
body: <p>I've a simple data structure (the <code>Transaction</code> referenced below) to be inserted into mongodb:</p>
  
  <pre><code>{"amount":111,"debitAcc":"588188286231743e7d5c923d","type":"CHARGE"}
  </code></pre>
  
  <p>An I got the following error stack：</p>
  
  <pre><code>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:494)
          at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:224)
          at com.mongodb.connection.UsageTrackingInternalConnection.receiveMessage(UsageTrackingInternalConnection.java:96)
          at com.mongodb.connection.DefaultConnectionPool$PooledConnection.receiveMessage(DefaultConnectionPool.java:440)
          at com.mongodb.connection.WriteCommandProtocol.receiveMessage(WriteCommandProtocol.java:262)
          at com.mongodb.connection.WriteCommandProtocol.execute(WriteCommandProtocol.java:104)
          at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:67)
          at com.mongodb.connection.InsertCommandProtocol.execute(InsertCommandProtocol.java:37)
          at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:168)
          at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:289)
          at com.mongodb.connection.DefaultServerConnection.insertCommand(DefaultServerConnection.java:118)
          at com.mongodb.operation.InsertOperation.executeCommandProtocol(InsertOperation.java:76)
          at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:139)
          at com.mongodb.operation.BaseWriteOperation$1.call(BaseWriteOperation.java:133)
          at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:422)
          at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:413)
          at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:133)
          at com.mongodb.operation.BaseWriteOperation.execute(BaseWriteOperation.java:60)
          at com.mongodb.Mongo.execute(Mongo.java:845)
          at com.mongodb.Mongo$2.execute(Mongo.java:828)
          at com.mongodb.DBCollection.executeWriteOperation(DBCollection.java:342)
          at com.mongodb.DBCollection.insert(DBCollection.java:337)
          at com.mongodb.DBCollection.insert(DBCollection.java:328)
          at org.mongodb.morphia.DatastoreImpl.saveDocument(DatastoreImpl.java:1297)
          at org.mongodb.morphia.DatastoreImpl.tryVersionedUpdate(DatastoreImpl.java:1340)
          at org.mongodb.morphia.DatastoreImpl.save(DatastoreImpl.java:1286)
          at org.mongodb.morphia.DatastoreImpl.save(DatastoreImpl.java:775)
          at org.mongodb.morphia.DatastoreImpl.save(DatastoreImpl.java:758)
  </code></pre>
  
  <p>My mongodb version is <code>3.4.2</code>.</p>
  
  <p>Intereting is that I don't have the issue on my local dev environment (mint linux 18.1). But it just can't work on my SIT environment, which is a ubuntu 16.04</p>
  
  <p>Any idea?</p>
  
  <p><strong>Updates with code to insert the document</strong></p>
  
  <p><a href="https://i.stack.imgur.com/oR6Oi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oR6Oi.png" alt="enter image description here"></a></p>
  
  <p>Where <code>transactionDao.save(...)</code> implementation could be found at:</p>
  
  <p><a href="https://github.com/actframework/act-morphia/blob/master/src/main/java/act/db/morphia/MorphiaDaoBase.java#L206" rel="nofollow noreferrer">https://github.com/actframework/act-morphia/blob/master/src/main/java/act/db/morphia/MorphiaDaoBase.java#L206</a></p>
  
  <p><strong>update 2</strong> </p>
  
  <p>The system works with other writes (even with much bigger records)</p>