I use this connection url to connect mongodb instance through driver
: mongodb://localhost:27017?ssl=true
and it works fine. But the same url doesn't work on mongo-shell instead I have to take out the ssl=true
parameter and use mongo mongodb://localhost:27017 --ssl
command. Why isn't they compatible with each other? Is there a universal url for both types of connections?
EDIT1
I have tried with mongo 3.4.3 and 3.4.2. Both version have the same issue.
Below is the detailed command and output I got:
mongo mongodb://host-1:27017,host-2:27017,host3:27017/admin?replicaSet=Cluster0-shard-0&ssl=true --username admin --password 123456
Below is the output:
connecting to: mongodb://host-1:27017,host-2:27017,host-3:27017/admin?replicaSet=Cluster0-shard-0
2017-04-10T20:52:09.345+1000 I NETWORK [thread1] Starting new replica set monitor for Cluster0-shard-0/host-1:27017,host-2:27017,host-3:27017
2017-04-10T20:52:09.416+1000 I NETWORK [thread1] Socket recv() Connection reset by peer 13.54.24.198:27017
2017-04-10T20:52:09.416+1000 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [13.54.24.198:27017]
2017-04-10T20:52:09.416+1000 W NETWORK [thread1] No primary detected for set Cluster0-shard-0
2017-04-10T20:52:09.416+1000 I NETWORK [thread1] All nodes for set Cluster0-shard-0 are down. This has happened for 1 checks in a row.
2017-04-10T20:52:09.987+1000 I NETWORK [thread1] Socket recv() Connection reset by peer 13.54.31.109:27017
2017-04-10T20:52:09.987+1000 I NETWORK [thread1] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [13.54.31.109:27017]
2017-04-10T20:52:10.019+1000 W NETWORK [thread1] No primary detected for set Cluster0-shard-0
2017-04-10T20:52:10.019+1000 I NETWORK [thread1] All nodes for set Cluster0-sha
rd-0 are down. This has happened for 2 checks in a row.
2017-04-10T20:52:10.558+1000 I NETWORK [thread1] Socket recv() Connection reset
...
2017-04-10T20:53:44.940+1000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] SocketException: remote: (NONE):0 error: 9001 socket exception [RECV_ERROR] server [13.54.31.109:27017]
答案 0 :(得分:0)
This should be fixed if you use mongo shell version >= 3.4.
Assuming that you are connecting using a 3.4 shell, the command line and the output would look something like this:
mongo "mongodb://localhost:27017/test?ssl=true" --authenticationDatabase admin --username xxx --password xxx
MongoDB shell version v3.4.3
connecting to: mongodb://localhost:27017/test?ssl=true
MongoDB server version: 3.4.3
>