com.mongodb.MongoSocketReadException: Prematurely reached end of stream

JIRA | Dharshan Rangegowda | 1 year ago
  1. 0

    I am trying to unlock a locked 3.x database. {code:java} public static void unlockMongoDB(MongoClient m) throws Exception { String context = "MongoDBHelper-unlockMongoDB: "; Logger.info(context + "Checking if MongoDB instance needs to be unlocked"); if(m.isLocked()) { Logger.info(context + "Unlocking MongoDB instance"); m.unlock(); } } {code} isLocked() fails with the following stack trace {noformat} 13 Jul 2015 02:20:20,893 ERROR ~ Prematurely reached end of stream 13 Jul 2015 02:20:20,894 ERROR ~ 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:491) at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:221) at com.mongodb.connection.UsageTrackingInternalConnection.receiveMessage(UsageTrackingInternalConnection.java:102) at com.mongodb.connection.DefaultConnectionPool$PooledConnection.receiveMessage(DefaultConnectionPool.java:416) at com.mongodb.connection.QueryProtocol.receiveMessage(QueryProtocol.java:282) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:229) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:38) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) at com.mongodb.connection.DefaultServerConnection.query(DefaultServerConnection.java:166) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:397) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:394) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168) at com.mongodb.operation.FindOperation.execute(FindOperation.java:394) at com.mongodb.operation.FindOperation.execute(FindOperation.java:57) at com.mongodb.Mongo.execute(Mongo.java:738) at com.mongodb.Mongo$2.execute(Mongo.java:725) at com.mongodb.DBCollection.findOne(DBCollection.java:737) at com.mongodb.DBCollection.findOne(DBCollection.java:710) at com.mongodb.DBCollection.findOne(DBCollection.java:657) at com.mongodb.DBCollection.findOne(DBCollection.java:646) at com.mongodb.Mongo.isLocked(Mongo.java:574) {noformat} Also I have noticed that if I pass the MongoClient object to another function and unlock it, the unlock appears to hang. If I use a try {} finally {} and unlock, it appears to go through.

    JIRA | 1 year ago | Dharshan Rangegowda
    com.mongodb.MongoSocketReadException: Prematurely reached end of stream
  2. 0

    I am trying to unlock a locked 3.x database. {code:java} public static void unlockMongoDB(MongoClient m) throws Exception { String context = "MongoDBHelper-unlockMongoDB: "; Logger.info(context + "Checking if MongoDB instance needs to be unlocked"); if(m.isLocked()) { Logger.info(context + "Unlocking MongoDB instance"); m.unlock(); } } {code} isLocked() fails with the following stack trace {noformat} 13 Jul 2015 02:20:20,893 ERROR ~ Prematurely reached end of stream 13 Jul 2015 02:20:20,894 ERROR ~ 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:491) at com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:221) at com.mongodb.connection.UsageTrackingInternalConnection.receiveMessage(UsageTrackingInternalConnection.java:102) at com.mongodb.connection.DefaultConnectionPool$PooledConnection.receiveMessage(DefaultConnectionPool.java:416) at com.mongodb.connection.QueryProtocol.receiveMessage(QueryProtocol.java:282) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:229) at com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:38) at com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155) at com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219) at com.mongodb.connection.DefaultServerConnection.query(DefaultServerConnection.java:166) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:397) at com.mongodb.operation.FindOperation$1.call(FindOperation.java:394) at com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195) at com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168) at com.mongodb.operation.FindOperation.execute(FindOperation.java:394) at com.mongodb.operation.FindOperation.execute(FindOperation.java:57) at com.mongodb.Mongo.execute(Mongo.java:738) at com.mongodb.Mongo$2.execute(Mongo.java:725) at com.mongodb.DBCollection.findOne(DBCollection.java:737) at com.mongodb.DBCollection.findOne(DBCollection.java:710) at com.mongodb.DBCollection.findOne(DBCollection.java:657) at com.mongodb.DBCollection.findOne(DBCollection.java:646) at com.mongodb.Mongo.isLocked(Mongo.java:574) {noformat} Also I have noticed that if I pass the MongoClient object to another function and unlock it, the unlock appears to hang. If I use a try {} finally {} and unlock, it appears to go through.

    JIRA | 1 year ago | Dharshan Rangegowda
    com.mongodb.MongoSocketReadException: Prematurely reached end of stream
  3. 0

    MongoDB: java.lang.IllegalStateException: state should be: open

    Stack Overflow | 2 weeks ago | EVG
    com.mongodb.MongoSocketReadException: Prematurely reached end of stream
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Connecting to mongo database through SSH tunnel in Java

    Stack Overflow | 1 year ago | David V
    com.mongodb.MongoSocketReadException: Prematurely reached end of stream
  6. 0

    Mongeeze failed with replicaset and mongoProperties.setUri used

    GitHub | 8 months ago | UltimateFighter
    com.mongodb.MongoSocketReadException: Prematurely reached end of stream

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.mongodb.MongoSocketReadException

      Prematurely reached end of stream

      at com.mongodb.connection.SocketStream.read()
    2. MongoDB Java Driver
      Mongo.isLocked
      1. com.mongodb.connection.SocketStream.read(SocketStream.java:88)
      2. com.mongodb.connection.InternalStreamConnection.receiveResponseBuffers(InternalStreamConnection.java:491)
      3. com.mongodb.connection.InternalStreamConnection.receiveMessage(InternalStreamConnection.java:221)
      4. com.mongodb.connection.UsageTrackingInternalConnection.receiveMessage(UsageTrackingInternalConnection.java:102)
      5. com.mongodb.connection.DefaultConnectionPool$PooledConnection.receiveMessage(DefaultConnectionPool.java:416)
      6. com.mongodb.connection.QueryProtocol.receiveMessage(QueryProtocol.java:282)
      7. com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:229)
      8. com.mongodb.connection.QueryProtocol.execute(QueryProtocol.java:38)
      9. com.mongodb.connection.DefaultServer$DefaultServerProtocolExecutor.execute(DefaultServer.java:155)
      10. com.mongodb.connection.DefaultServerConnection.executeProtocol(DefaultServerConnection.java:219)
      11. com.mongodb.connection.DefaultServerConnection.query(DefaultServerConnection.java:166)
      12. com.mongodb.operation.FindOperation$1.call(FindOperation.java:397)
      13. com.mongodb.operation.FindOperation$1.call(FindOperation.java:394)
      14. com.mongodb.operation.OperationHelper.withConnectionSource(OperationHelper.java:195)
      15. com.mongodb.operation.OperationHelper.withConnection(OperationHelper.java:168)
      16. com.mongodb.operation.FindOperation.execute(FindOperation.java:394)
      17. com.mongodb.operation.FindOperation.execute(FindOperation.java:57)
      18. com.mongodb.Mongo.execute(Mongo.java:738)
      19. com.mongodb.Mongo$2.execute(Mongo.java:725)
      20. com.mongodb.DBCollection.findOne(DBCollection.java:737)
      21. com.mongodb.DBCollection.findOne(DBCollection.java:710)
      22. com.mongodb.DBCollection.findOne(DBCollection.java:657)
      23. com.mongodb.DBCollection.findOne(DBCollection.java:646)
      24. com.mongodb.Mongo.isLocked(Mongo.java:574)
      24 frames