Closed rshov closed 2 years ago
I'm seeing the same issue but with the node driver and not the shell.
"The client metadata document may only be sent in the first isMaster"
@rshov I've opened a PR that I believe will fix your issue: https://github.com/coinbase/mongobetween/pull/41
@rshov #41 has been merged, let us know if that fixes your issue
Sorry for not getting to this sooner, but I've been trying with the update and still cannot get it to work.
I start mongobetween with the following command:
./go/bin/mongobetween ":27017=mongodb+srv://username:password@prod.pips3.gcp.mongodb.net/dbname?maxpoolsize=10&label=cluster0"
That seems to connect ok to my Atlas database.
{"level":"info","ts":1640282695.3266177,"caller":"mongo/mongo.go:61","message":"Connect"}
{"level":"info","ts":1640282695.3398523,"caller":"mongobetween@v0.0.13/mongobetween.go:79","message":"Running"}
{"level":"info","ts":1640282700.3402007,"caller":"mongo/topology_monitor.go:19","message":"Topology changed","old_kind":"ReplicaSetNoPrimary","new_kind":"ReplicaSetWithPrimary","old_address_0":"prod-shard-00-00.pips3.gcp.mongodb.net:27017","old_kind_0":"Unknown","old_address_1":"prod-shard-00-01.pips3.gcp.mongodb.net:27017","old_kind_1":"Unknown","old_address_2":"prod-shard-00-02.pips3.gcp.mongodb.net:27017","old_kind_2":"Unknown","new_address_0":"prod-shard-00-00.pips3.gcp.mongodb.net:27017","new_kind_0":"RSSecondary","new_address_1":"prod-shard-00-01.pips3.gcp.mongodb.net:27017","new_kind_1":"RSSecondary","new_address_2":"prod-shard-00-02.pips3.gcp.mongodb.net:27017","new_kind_2":"RSPrimary"}
Then I run my application which tries to connect to mongobetween with this url (I've changed the actual IP here):
mongodb+srv://username:password@159.223.150.30/dbname
But my application gets this error:
Error: querySrv ENOTFOUND _mongodb._tcp.159.223.150.30
at QueryReqWrap.onresolve [as oncomplete] (node:dns:213:19) {
errno: undefined,
code: 'ENOTFOUND',
syscall: 'querySrv',
hostname: '_mongodb._tcp.159.223.150.30'
}
If I change the url that my app uses to connect to mongobetween, and take away the "+srv" part so it is:
mongodb://username:password@159.223.150.30/dbname
Then I see log output in mongobetween:
{"level":"info","ts":1640282935.0947332,"caller":"proxy/proxy.go:164","message":"Accept","cluster":"cluster0","remote_address":"40.200.3.16:54671"}
{"level":"info","ts":1640282935.2335684,"caller":"proxy/proxy.go:164","message":"Accept","cluster":"cluster0","remote_address":"40.200.3.16:54673"}
{"level":"info","ts":1640282935.5051587,"caller":"proxy/proxy.go:168","message":"Close","cluster":"cluster0","remote_address":"40.200.3.16:54671"}
{"level":"info","ts":1640282935.5087996,"caller":"proxy/proxy.go:168","message":"Close","cluster":"cluster0","remote_address":"40.200.3.16:54673"}
But my application shows an error:
MongoError: Authentication failed.
at MessageStream.messageHandler (/Users/raymond/Documents/GitHub/app/node_modules/mongodb/lib/cmap/connection.js:272:20)
at MessageStream.emit (node:events:390:28)
at processIncomingData (/Users/raymond/Documents/GitHub/app/node_modules/mongodb/lib/cmap/message_stream.js:144:12)
at MessageStream._write (/Users/raymond/Documents/GitHub/app/node_modules/mongodb/lib/cmap/message_stream.js:42:5)
at writeOrBuffer (node:internal/streams/writable:389:12)
at _write (node:internal/streams/writable:330:10)
at MessageStream.Writable.write (node:internal/streams/writable:334:10)
at Socket.ondata (node:internal/streams/readable:754:22)
at Socket.emit (node:events:390:28)
at addChunk (node:internal/streams/readable:315:12)
at readableAddChunk (node:internal/streams/readable:289:9)
at Socket.Readable.push (node:internal/streams/readable:228:10)
at TCP.onStreamRead (node:internal/stream_base_commons:199:23) {
operationTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1640283316 },
ok: 0,
code: 18,
codeName: 'AuthenticationFailed',
'$clusterTime': {
clusterTime: Timestamp { _bsontype: 'Timestamp', low_: 1, high_: 1640283316 },
signature: { hash: [Binary], keyId: [Long] }
}
}
Any ideas? I would really love to use mongobetween, but am really struggling to get it up and running.
Thanks for any help!
@rshov did you ever manage to use it?
@rshov did you ever manage to use it?
No, I never did get it working unfortunately
Hello, thank you for open sourcing this project, it seems to be just what I need for my Next.js application which deploys my API as AWS Lambda functions, causing way too many database connections.
Unfortunately I can't seem to get mongobetween working. It connects to my database ok, but my application is not able to connect to mongobetween. I'm hoping to get some help.
I'm attempting to use mongobetween to proxy to a MongoDB Atlas database at version 4.4.6 (it's a 3-node replica set with no sharding). My application uses Mongoose 5.11.8 (which uses the MongoDB Node.js driver, I'm assuming v3.6 but I couldn't confirm this). I spun up a basic server on DigitalOcean and installed Go v1.16.5 with the latest mongobetween.
Command used to start mongobetween:
./go/bin/mongobetween -pretty -loglevel debug ":27016=mongodb+srv://username:password@server.mongodb.net/database?maxpoolsize=50&label=cluster0"
MongoBetween seems to connect to my Atlas database ok, but my application receives the following error:
I then tried connecting directly from the mongo shell and got Authentication failed:
Could this be from using too new of a Mongo client version? Thank you so much for any help you can provide.
Raymond