MongoDB: Missing `&ssl=true` leads to `Error: unexpected end of file` on multi hostname connection string
See original GitHub issueI have a multi hostname connection string like mongodb://user:password@cluster0-shard-00-00.bsdflt.mongodb.net:27017,cluster0-shard-00-01.bsdflt.mongodb.net:27017,cluster0-shard-00-02.bsdflt.mongodb.net:27017/test?retryWrites=true&w=majority&authSource=admin
. Using it with Prisma Client leads to this error message:
$ ts-node ./script.ts
PrismaClientInitializationError:
Invalid `client.user.deleteMany()` invocation in
/home/runner/work/e2e-tests/e2e-tests/databases/mongodb-atlas-sharded/script.ts:7:21
4
5 // A `main` function so that we can use async/await
6 async function main() {
→ 7 await client.user.deleteMany(
Database error. error code: unknown, error message: Server selection timeout: No available servers. Topology: { Type: Unknown, Servers: [ { Address: cluster0-shard-00-02.bu2lt.mongodb.net:27017, Type: Unknown, Error: unexpected end of file }, { Address: cluster0-shard-00-01.bu2lt.mongodb.net:27017, Type: Unknown, Error: unexpected end of file }, { Address: cluster0-shard-00-00.bu2lt.mongodb.net:27017, Type: Unknown, Error: unexpected end of file }, ] }
at cb (/home/runner/work/e2e-tests/e2e-tests/databases/mongodb-atlas-sharded/node_modules/@prisma/client/runtime/index.js:39812:17) {
clientVersion: '3.10.0-dev.71',
errorCode: undefined
}
error Command failed with exit code 1.
Adding &ssl=true
to the connection string makes the script succeed.
(I got this connection string by manually converting a mongodb+srv
one to a normal mongodb
one that lists the shards in the hostname with comma separation.)
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Connection issue with mongoose db error for multiple host ...
I am trying to connect to a mongodb atlas free cluster. however the error tells me that connection string can not contain multiple...
Read more >MongoClient or how to connect in a new and better way
The main difference is that the constructor is missing the database name from Db. Let's show a simple connection using open as a...
Read more >mongo_client – Tools for connecting to MongoDB - PyMongo
The client object is thread-safe and has connection-pooling built in. If an operation fails because of a network error, ConnectionFailure is raised and...
Read more >Mongoose v6.8.1: Connecting to MongoDB
See the mongodb connection string spec for more details. ... Replica Set Host Names; Multi-mongos support; Multiple connections; Connection Pools ...
Read more >Connecting MongoDB To Ruby With Self-Signed SSL ...
First, find and copy your MongoDB connection string from the ... due to: Mongo::Error::SocketError EOFError: end of file reached (for ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Open a new issue for this please @moersoy, this one is explicitly for multi hostname connection strings. Thanks.
I’m getting this error even though there is only one hostname connection. This error usually appeared when the number of instant connections was high.
“@prisma/client”: “4.5.0”, node:16-alpine, Google CloudRun