0

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]
Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523

1 Answers1

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
>
helmy
  • 9,068
  • 3
  • 32
  • 31
  • I am having this issue with mongo shell `v3.4.2`. – Joey Yi Zhao Apr 10 '17 at 04:43
  • Can you please update your question to show the exact command line output that you're getting, including the call to mongo shell and the error message? See my revised answer for sample output from a 3.4 shell. – helmy Apr 10 '17 at 05:27
  • you have ``ssh=true`` in your connection string it should be **ssl=true** – helmy Apr 10 '17 at 14:39
  • Sorry this is a typo. I have corrected it in my question. But it is still the same error. – Joey Yi Zhao Apr 10 '17 at 23:16
  • Can you try to simplify your test case to only connect to 1 server. e.g. put just 1 host in the list and remove the ``replicaSet=Cluster0-shard-0`` from the connection string. The output from that might help to better identify the problem. Also look in the mongod.log file for the 1 server that you are connecting to, and see what messages are logged during the connection attempt. – helmy Apr 10 '17 at 23:31
  • Just tried that connect to one host without `replicaSet` works fine. the problem happens when connect to multiple host with `replicaSet` parameter. – Joey Yi Zhao Apr 10 '17 at 23:40
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/141393/discussion-between-helmy-and-zhao-yi). – helmy Apr 11 '17 at 00:01
  • Did you guys ever figure out what the issue was? I'm having the same problems with connecting, and I'm using mongo v3.4.2 – sabliao Jun 23 '17 at 22:19
  • Not from my end, I'd suggest posting a new question with the details of your issue. – helmy Jun 23 '17 at 22:32