Mongodb: `com.mongodb.MongoSocketReadException: Prematurely reached end of stream` with morphia
Most of the time this is a result of timeouts with long reads\writes.
try to increase the timeouts or remove them completely:
MongoClientOptions.Builder options_builder = new MongoClientOptions.Builder();
options_builder.maxConnectionIdleTime(<some_long_time>);
MongoClientOptions options = options_builder.build();
MongoClient mongo_db = new MongoClient ("your.db.address", options);
I don't have the root cause, but in the end I get the issue fixed by changing a field type from BigDecimal
to double
.
The issue is found in our SIT environmet and one developer's windows environment which has a mongodb cluser setup.
The most likely reason is the compatibility version is set too low.
Try db.adminCommand( { setFeatureCompatibilityVersion: "3.4" } )
https://docs.mongodb.com/manual/reference/command/setFeatureCompatibilityVersion/