简体   繁体   English

Mongo客户端尝试关闭不存在/创建的连接,并因MongoSocketReadException失败:过早到达流的末尾

[英]Mongo client trying to close connection that didn't exist/create and fails with MongoSocketReadException: Prematurely reached end of stream

I see my app log with lot of "com.mongodb.MongoSocketReadException: Prematurely reached end of stream" in DEBUG mode when it is trying to close mongo connections. 当尝试关闭mongo连接时, 在调试模式下看到很多“ com.mongodb.MongoSocketReadException:过早到达流尾”的应用日志 My analysis so far is that I don't see that connection got created in the logs as per the connection id of format connectionId{localValue:8} 到目前为止,我的分析是,我没有看到按照格式connectionId {localValue:8}的连接ID在日志中创建连接

NOTE: Same code works fine with org.mongodb:mongodb-driver:3.4.2, but we see warnings with 3.6.3 注意:相同的代码可与org.mongodb:mongodb-driver:3.4.2正常工作,但在3.6.3中会看到警告

Mongo Client Version# 3.6.3 Mongo Server Version# 3.2.6 (3 node replica set) Mongo dependencies# org.springframework.data:spring-data-mongodb:1.8.2.RELEASE , org.mongodb:mongodb-driver:3.6.3 Mongo客户端版本#3.6.3 Mongo服务器版本#3.2.6(3个节点副本集)Mongo依赖项#org.springframework.data:spring-data-mongodb:1.8.2.RELEASE,org.mongodb:mongodb-driver:3.6 0.3

I did refer to Mongo Java Driver -prematurely reached end of stream exception? 我确实参考了Mongo Java驱动程序-过早到达流末尾异常? and tried the following settings, but it didn't help. 并尝试了以下设置,但没有帮助。

Mongo client configuration Mongo客户端配置

<mongo:mongo-client id="sslmongosfp" replica-set="${mongodb.replication.set}" credentials="${MONGO_USER}@${mongodb.dbname}">
    <mongo:client-options ssl="true"
      socket-keep-alive="${mongo.socketKeepAlive:true}"
      socket-timeout="${mongo.socketTimeout:180000}"
      heartbeat-connect-timeout="${mongo.heartbeat.connectTimeout:60000}"
      heartbeat-socket-timeout="${mongo.socketTimeout:180000}"
      max-connection-idle-time="${mongo.max.connection.idle:300000}" />
</mongo:mongo-client>

My app connects to 2 different schemas on the same replicaset. 我的应用程序连接到同一副本集上的2个不同架构。

Application Logs filtered with relevant info 使用相关信息过滤的应用程序日志

[localhost-startStop-1] 2018-08-07 12:39:57,546  org.mongodb.driver.cluster - Cluster created with settings {hosts=[MyServer1:27017, MyServer3:27017, MyServer2:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[localhost-startStop-1] 2018-08-07 12:39:57,552  org.mongodb.driver.cluster - Adding discovered server MyServer1:27017 to client view of cluster
[MaintenanceTimer-1-thread-1] 2018-08-07 12:39:57,585  org.mongodb.driver.connection - Pruning pooled connections to MyServer1:27017
[localhost-startStop-1] 2018-08-07 12:39:57,609  org.mongodb.driver.cluster - Adding discovered server MyServer3:27017 to client view of cluster
[MaintenanceTimer-2-thread-1] 2018-08-07 12:39:57,610  org.mongodb.driver.connection - Pruning pooled connections to MyServer3:27017
[localhost-startStop-1] 2018-08-07 12:39:57,611  org.mongodb.driver.cluster - Adding discovered server MyServer2:27017 to client view of cluster
[MaintenanceTimer-3-thread-1] 2018-08-07 12:39:57,612  org.mongodb.driver.connection - Pruning pooled connections to MyServer2:27017
[localhost-startStop-1] 2018-08-07 12:39:57,616  org.mongodb.driver.cluster - Updating cluster description to  {type=UNKNOWN, servers=[{address=MyServer1:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[localhost-startStop-1] 2018-08-07 12:39:57,879  org.mongodb.driver.cluster - Cluster created with settings {hosts=[MyServer1:27017, MyServer3:27017, MyServer2:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[localhost-startStop-1] 2018-08-07 12:39:57,879  org.mongodb.driver.cluster - Adding discovered server MyServer1:27017 to client view of cluster
[MaintenanceTimer-5-thread-1] 2018-08-07 12:39:57,880  org.mongodb.driver.connection - Pruning pooled connections to MyServer1:27017
[localhost-startStop-1] 2018-08-07 12:39:57,881  org.mongodb.driver.cluster - Adding discovered server MyServer3:27017 to client view of cluster
[MaintenanceTimer-6-thread-1] 2018-08-07 12:39:57,882  org.mongodb.driver.connection - Pruning pooled connections to MyServer3:27017
[localhost-startStop-1] 2018-08-07 12:39:57,882  org.mongodb.driver.cluster - Adding discovered server MyServer2:27017 to client view of cluster
[MaintenanceTimer-7-thread-1] 2018-08-07 12:39:57,885  org.mongodb.driver.connection - Pruning pooled connections to MyServer2:27017
[localhost-startStop-1] 2018-08-07 12:39:57,886  org.mongodb.driver.cluster - Updating cluster description to  {type=UNKNOWN, servers=[{address=MyServer1:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,168  org.mongodb.driver.connection - Opened connection [connectionId{localValue:2, serverValue:41448917}] to MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,168  org.mongodb.driver.cluster - Checking status of MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,173  org.mongodb.driver.connection - Opened connection [connectionId{localValue:3, serverValue:41047679}] to MyServer2:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,173  org.mongodb.driver.cluster - Checking status of MyServer2:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,215  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=MyServer2:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 6]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=40007177, setName='rs0', canonicalAddress=MyServer2:27017, hosts=[MyServer1:27017, MyServer2:27017, MyServer3:27017], passives=[], arbiters=[], primary='MyServer1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=11, lastWriteDate=null, lastUpdateTimeNanos=634155407285407}
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,215  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 6]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=42769620, setName='rs0', canonicalAddress=MyServer1:27017, hosts=[MyServer1:27017, MyServer2:27017, MyServer3:27017], passives=[], arbiters=[], primary='MyServer1:27017', tagSet=TagSet{[]}, electionId=7fffffff000000000000002d, setVersion=11, lastWriteDate=null, lastUpdateTimeNanos=634155408436207}
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,218  org.mongodb.driver.cluster - Discovered cluster type of REPLICA_SET
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,219  org.mongodb.driver.cluster - Setting max election id to 7fffffff000000000000002d from replica set primary MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,220  org.mongodb.driver.cluster - Setting max set version to 11 from replica set primary MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,220  org.mongodb.driver.cluster - Discovered replica set primary MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,220  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=42.8 ms, state=CONNECTED}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,221  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=42.8 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=40.0 ms, state=CONNECTED}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,296  org.mongodb.driver.connection - Opened connection [connectionId{localValue:4, serverValue:41448920}] to MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,296  org.mongodb.driver.cluster - Checking status of MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,296  org.mongodb.driver.connection - Opened connection [connectionId{localValue:6, serverValue:41047689}] to MyServer2:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,296  org.mongodb.driver.cluster - Checking status of MyServer2:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,310  org.mongodb.driver.connection - Opened connection [connectionId{localValue:1, serverValue:15360985}] to MyServer3:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,311  org.mongodb.driver.cluster - Checking status of MyServer3:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,335  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 6]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=38447323, setName='rs0', canonicalAddress=MyServer1:27017, hosts=[MyServer1:27017, MyServer2:27017, MyServer3:27017], passives=[], arbiters=[], primary='MyServer1:27017', tagSet=TagSet{[]}, electionId=7fffffff000000000000002d, setVersion=11, lastWriteDate=null, lastUpdateTimeNanos=634155527879863}
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,335  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=MyServer2:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 6]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=38707927, setName='rs0', canonicalAddress=MyServer2:27017, hosts=[MyServer1:27017, MyServer2:27017, MyServer3:27017], passives=[], arbiters=[], primary='MyServer1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=11, lastWriteDate=null, lastUpdateTimeNanos=634155528294115}
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,336  org.mongodb.driver.cluster - Discovered cluster type of REPLICA_SET
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,336  org.mongodb.driver.cluster - Setting max election id to 7fffffff000000000000002d from replica set primary MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,336  org.mongodb.driver.cluster - Setting max set version to 11 from replica set primary MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,336  org.mongodb.driver.cluster - Discovered replica set primary MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:39:58,336  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=38.4 ms, state=CONNECTED}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer2:27017] 2018-08-07 12:39:58,336  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=38.4 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=38.7 ms, state=CONNECTED}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,577  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=MyServer3:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 6]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=266413679, setName='rs0', canonicalAddress=MyServer3:27017, hosts=[MyServer1:27017, MyServer2:27017, MyServer3:27017], passives=[], arbiters=[], primary='MyServer1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=11, lastWriteDate=null, lastUpdateTimeNanos=634155770298051}
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,578  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=42.8 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=40.0 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=266.4 ms, state=CONNECTED}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,626  org.mongodb.driver.connection - Opened connection [connectionId{localValue:5, serverValue:15360986}] to MyServer3:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,626  org.mongodb.driver.cluster - Checking status of MyServer3:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,677  org.mongodb.driver.cluster - Monitor thread successfully connected to server with description ServerDescription{address=MyServer3:27017, type=REPLICA_SET_SECONDARY, state=CONNECTED, ok=true, version=ServerVersion{versionList=[3, 2, 6]}, minWireVersion=0, maxWireVersion=4, maxDocumentSize=16777216, logicalSessionTimeoutMinutes=null, roundTripTimeNanos=50611106, setName='rs0', canonicalAddress=MyServer3:27017, hosts=[MyServer1:27017, MyServer2:27017, MyServer3:27017], passives=[], arbiters=[], primary='MyServer1:27017', tagSet=TagSet{[]}, electionId=null, setVersion=11, lastWriteDate=null, lastUpdateTimeNanos=634155870321060}
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer3:27017] 2018-08-07 12:39:58,678  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=38.4 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=38.7 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=50.6 ms, state=CONNECTED}]
[localhost-startStop-1] 2018-08-07 12:40:00,930  org.mongodb.driver.connection - Opened connection [connectionId{localValue:7, serverValue:41448934}] to MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:40:08,223  org.mongodb.driver.cluster - Checking status of MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer2:27017] 2018-08-07 12:40:08,223  org.mongodb.driver.cluster - Checking status of MyServer2:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer1:27017] 2018-08-07 12:40:08,256  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=40.7 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=40.0 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=266.4 ms, state=CONNECTED}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer2:27017] 2018-08-07 12:40:08,262  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=40.7 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=39.5 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=266.4 ms, state=CONNECTED}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:40:08,339  org.mongodb.driver.cluster - Checking status of MyServer1:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer2:27017] 2018-08-07 12:40:08,339  org.mongodb.driver.cluster - Checking status of MyServer2:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer2:27017] 2018-08-07 12:40:08,436  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=38.4 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=50.2 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=50.6 ms, state=CONNECTED}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer1:27017] 2018-08-07 12:40:08,441  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=51.0 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=50.2 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=50.6 ms, state=CONNECTED}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer3:27017] 2018-08-07 12:40:08,581  org.mongodb.driver.cluster - Checking status of MyServer3:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6a', description='null'}-MyServer3:27017] 2018-08-07 12:40:08,631  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=40.7 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=39.5 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=222.9 ms, state=CONNECTED}]
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer3:27017] 2018-08-07 12:40:08,681  org.mongodb.driver.cluster - Checking status of MyServer3:27017
[cluster-ClusterId{value='5b69cb5dd33cf25160031d6b', description='null'}-MyServer3:27017] 2018-08-07 12:40:08,735  org.mongodb.driver.cluster - Updating cluster description to  {type=REPLICA_SET, servers=[{address=MyServer1:27017, type=REPLICA_SET_PRIMARY, roundTripTime=51.0 ms, state=CONNECTED}, {address=MyServer2:27017, type=REPLICA_SET_SECONDARY, roundTripTime=50.2 ms, state=CONNECTED}, {address=MyServer3:27017, type=REPLICA_SET_SECONDARY, roundTripTime=50.2 ms, state=CONNECTED}]
[localhost-startStop-1] 2018-08-07 12:40:11,749  org.mongodb.driver.cluster - Cluster created with settings {hosts=[MyServer1:27017, MyServer3:27017, MyServer2:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[localhost-startStop-1] 2018-08-07 12:40:11,749  org.mongodb.driver.cluster - Adding discovered server MyServer1:27017 to client view of cluster
[MaintenanceTimer-9-thread-1] 2018-08-07 12:40:11,750  org.mongodb.driver.connection - Pruning pooled connections to MyServer1:27017
[localhost-startStop-1] 2018-08-07 12:40:11,751  org.mongodb.driver.cluster - Adding discovered server MyServer3:27017 to client view of cluster
[MaintenanceTimer-10-thread-1] 2018-08-07 12:40:11,753  org.mongodb.driver.connection - Pruning pooled connections to MyServer3:27017
[localhost-startStop-1] 2018-08-07 12:40:11,755  org.mongodb.driver.cluster - Adding discovered server MyServer2:27017 to client view of cluster
[MaintenanceTimer-11-thread-1] 2018-08-07 12:40:11,757  org.mongodb.driver.connection - Pruning pooled connections to MyServer2:27017
[localhost-startStop-1] 2018-08-07 12:40:11,759  org.mongodb.driver.cluster - Updating cluster description to  {type=UNKNOWN, servers=[{address=MyServer1:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[localhost-startStop-1] 2018-08-07 12:40:11,765  org.mongodb.driver.cluster - Cluster created with settings {hosts=[MyServer1:27017, MyServer3:27017, MyServer2:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[localhost-startStop-1] 2018-08-07 12:40:11,765  org.mongodb.driver.cluster - Adding discovered server MyServer1:27017 to client view of cluster
[MaintenanceTimer-13-thread-1] 2018-08-07 12:40:11,767  org.mongodb.driver.connection - Pruning pooled connections to MyServer1:27017
[localhost-startStop-1] 2018-08-07 12:40:11,767  org.mongodb.driver.cluster - Adding discovered server MyServer3:27017 to client view of cluster
[MaintenanceTimer-14-thread-1] 2018-08-07 12:40:11,769  org.mongodb.driver.connection - Pruning pooled connections to MyServer3:27017
[localhost-startStop-1] 2018-08-07 12:40:11,770  org.mongodb.driver.cluster - Adding discovered server MyServer2:27017 to client view of cluster
[MaintenanceTimer-15-thread-1] 2018-08-07 12:40:11,772  org.mongodb.driver.connection - Pruning pooled connections to MyServer2:27017
[localhost-startStop-1] 2018-08-07 12:40:11,774  org.mongodb.driver.cluster - Updating cluster description to  {type=UNKNOWN, servers=[{address=MyServer1:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[localhost-startStop-1] 2018-08-07 12:40:11,787  org.mongodb.driver.cluster - Cluster created with settings {hosts=[MyServer1:27017, MyServer3:27017, MyServer2:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[localhost-startStop-1] 2018-08-07 12:40:11,787  org.mongodb.driver.cluster - Adding discovered server MyServer1:27017 to client view of cluster
[MaintenanceTimer-17-thread-1] 2018-08-07 12:40:11,788  org.mongodb.driver.connection - Pruning pooled connections to MyServer1:27017
[localhost-startStop-1] 2018-08-07 12:40:11,788  org.mongodb.driver.cluster - Adding discovered server MyServer3:27017 to client view of cluster
[MaintenanceTimer-18-thread-1] 2018-08-07 12:40:11,789  org.mongodb.driver.connection - Pruning pooled connections to MyServer3:27017
[localhost-startStop-1] 2018-08-07 12:40:11,790  org.mongodb.driver.cluster - Adding discovered server MyServer2:27017 to client view of cluster
[MaintenanceTimer-19-thread-1] 2018-08-07 12:40:11,791  org.mongodb.driver.connection - Pruning pooled connections to MyServer2:27017
[localhost-startStop-1] 2018-08-07 12:40:11,792  org.mongodb.driver.cluster - Updating cluster description to  {type=UNKNOWN, servers=[{address=MyServer1:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[localhost-startStop-1] 2018-08-07 12:40:11,795  org.mongodb.driver.cluster - Cluster created with settings {hosts=[MyServer1:27017, MyServer3:27017, MyServer2:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN, serverSelectionTimeout='30000 ms', maxWaitQueueSize=500}
[localhost-startStop-1] 2018-08-07 12:40:11,795  org.mongodb.driver.cluster - Adding discovered server MyServer1:27017 to client view of cluster
[MaintenanceTimer-21-thread-1] 2018-08-07 12:40:11,796  org.mongodb.driver.connection - Pruning pooled connections to MyServer1:27017
[localhost-startStop-1] 2018-08-07 12:40:11,797  org.mongodb.driver.cluster - Adding discovered server MyServer3:27017 to client view of cluster
[MaintenanceTimer-22-thread-1] 2018-08-07 12:40:11,798  org.mongodb.driver.connection - Pruning pooled connections to MyServer3:27017
[localhost-startStop-1] 2018-08-07 12:40:11,799  org.mongodb.driver.cluster - Adding discovered server MyServer2:27017 to client view of cluster
[MaintenanceTimer-23-thread-1] 2018-08-07 12:40:11,801  org.mongodb.driver.connection - Pruning pooled connections to MyServer2:27017
[localhost-startStop-1] 2018-08-07 12:40:11,802  org.mongodb.driver.cluster - Updating cluster description to  {type=UNKNOWN, servers=[{address=MyServer1:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer2:27017, type=UNKNOWN, state=CONNECTING}, {address=MyServer3:27017, type=UNKNOWN, state=CONNECTING}]
[cluster-ClusterId{value='5b69cb6bd33cf25160031d6c', description='null'}-MyServer1:27017] 2018-08-07 12:40:11,865  org.mongodb.driver.connection - Closing connection connectionId{localValue:8}
[cluster-ClusterId{value='5b69cb6bd33cf25160031d6c', description='null'}-MyServer1:27017] 2018-08-07 12:40:11,865  org.mongodb.driver.cluster - Exception in monitor thread while connecting to server MyServer1:27017
com.mongodb.MongoSocketReadException: Prematurely reached end of stream
    at com.mongodb.connection.SocketStream.read(SocketStream.java:87)

Useful info 有用的信息

My application log first statement started @ 2018-08-07 12:39:47,040 我的应用程序日志第一条语句开始于@ 2018-08-07 12:39:47,040

Prematurely reached end of stream started @ 2018-08-07 12:40:11,865 and this error repeats for ever. 流已过早到达结束@ 2018-08-07 12:40:11,865,并且此错误永远重复。

From the log below, I figured out that mongo client options are not set correctly Cluster created with settings {hosts=[MyServer1:27017, MyServer3:27017, MyServer2:27017], mode=MULTIPLE, requiredClusterType=UNKNOWN , serverSelectionTimeout='30000 ms', maxWaitQueueSize=500} 从下面的日志中,我发现mongo客户端选项未正确设置使用设置{hosts = [MyServer1:27017,MyServer3:27017,MyServer2:27017],mode = MULTIPLE, requiredClusterType = UNKNOWN ,serverSelectionTimeout ='30000 ms创建的集群',maxWaitQueueSize = 500}

Updating my mongo configuration to use the following did the trick and worked 更新我的mongo配置以使用以下技巧并成功了

<bean id="mongosfpUri" class="com.mongodb.MongoClientURI">
    <!-- refer https://docs.mongodb.com/manual/reference/connection-string/ -->
    <constructor-arg value="${mongodb.uri}"/>
</bean>

<bean id="mongosfp" class="com.mongodb.MongoClient">
    <constructor-arg ref="mongosfpUri"/>
</bean>

<mongo:db-factory id="mongoDbFactory" dbname="${mongodb.dbname}" mongo-ref="mongosfp" />

<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
    <constructor-arg ref="mongoDbFactory" />
    <constructor-arg ref="mongoConverter" />
</bean>

<bean id="mongoConverter" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
    <constructor-arg ref="mongoDbFactory" />
    <constructor-arg>
        <bean class="org.springframework.data.mongodb.core.mapping.MongoMappingContext" />
    </constructor-arg>
    <property name="mapKeyDotReplacement" value="%2E" />
</bean>

Here is the sample mongodb.uri 这是样例mongodb.uri

mongodb.uri=mongodb://user:password@MyServer1:27017,MyServer2:27017,MyServer3:27017/mydb?replicaSet=rs0&ssl=true&sslInvalidHostNameAllowed=true&heartbeatFrequencyMS=10000

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoSocketReadException:过早到达流末尾(使用 ssl 从 Java 到 Mongo) - MongoSocketReadException: Prematurely reached end of stream (Java to Mongo using ssl) 如何修复 com.mongo.MongoSocketReadException 并在尝试插入文档时出现消息“过早到达 Stream 的末尾”? - How do I fix a com.mongo.MongoSocketReadException, with the message "Prematurely reached the end of Stream" on attempting to insert a document? MongoClientURI 连接字符串抛出错误“com.mongodb.MongoSocketReadException:过早到达流的末尾” - MongoClientURI connection string throwing error “com.mongodb.MongoSocketReadException: Prematurely reached end of stream” mongoDB和Spark:“ com.mongodb.MongoSocketReadException:过早到达流的末尾” - mongoDB & Spark: “com.mongodb.MongoSocketReadException: Prematurely reached end of stream” MongoSocketReadException:过早到达 stream 的末尾(一段时间不活动后) - MongoSocketReadException: Prematurely reached end of stream (after a period of inactivity) com.mongodb.MongoSocketReadException:过早到达流的结尾 - com.mongodb.MongoSocketReadException: Prematurely reached end of stream 将Java应用程序连接到MongoDB-com.mongodb.MongoSocketReadException:已提前到达流的末尾 - Connect Java- Application to MongoDB - com.mongodb.MongoSocketReadException: Prematurely reached end of stream 获取com.mongodb.MongoSocketReadException:过早地到达流MongoDB的末尾 - Getting com.mongodb.MongoSocketReadException: Prematurely reached end of stream- MongoDB MongoSocketReadException:在 Spring 引导连接 MongoDB Atlas 时,过早到达 stream 的末尾 - MongoSocketReadException :Prematurely reached end of stream ,while connecting MongoDB Atlas by Spring Boot 读取inputstream时过早到达DB2流的末尾 - DB2 end of stream prematurely reached while reading inputstream
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM