title: Heroku MongoSocketReadException: Prematurely reached end of stream
body: <p>I (cannot) run my application on Heroku. It works fine on a local run but cloud. I do not understand the real reason.</p>
  
  <ul>
  <li>Cloud mongodb cluster</li>
  <li>Spring Boot app on Heroku</li>
  </ul>
  
  <p><strong>application.properties:</strong></p>
  
  <pre><code>spring.data.mongodb.uri=mongodb+srv://demo-user:demo@demo-******u.mongodb.net/test?retryWrites=true&amp;w=majority&amp;serverSelectionTimeoutMS=60000&amp;connectTimeoutMS=60000
  spring.data.mongodb.database=test
  </code></pre>
  
  <p><strong>Heroku Console Log:</strong></p>
  
  <pre><code>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
  </code></pre>