我(无法)在Heroku上运行我的应用程序。它在本地运行但在云上运行良好。我不明白真正的原因。
application.properties:
spring.data.mongodb.uri=mongodb+srv://demo-user:demo@demo-******u.mongodb.net/test?retryWrites=true&w=majority&serverSelectionTimeoutMS=60000&connectTimeoutMS=60000
spring.data.mongodb.database=test
Heroku控制台日志:
2019-09-09T14:56:51.741370+00:00 app[web.1]: 2019-09-09 14:56:51.741 INFO 4 --- [ main] org.mongodb.driver.cluster : No server chosen by com.mongodb.client.internal.MongoClientDelegate$1@7d9d0818 from cluster description ClusterDescription{type=REPLICA_SET, connectionMode=MULTIPLE, serverDescriptions=[ServerDescription{address=demo-carp*****u.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}, ServerDescription{address=demo-carpool-shard-00-00-hrjju.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}, ServerDescription{address=demo-ca*****rjju.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]}. Waiting for 60000 ms before timing out
答案 0 :(得分:0)
问题与Mongodb云网络访问设置有关。 有一个称为“白名单”的概念。我家的IP地址已添加到那里,但云服务器的IP地址已添加到那里。我也必须添加服务器的IP地址。
答案 1 :(得分:0)
您需要同时添加家庭IP地址和服务器的IP地址。另外,群集的名称区分大小写。这也可能导致错误