【发布时间】:2020-10-01 23:01:53
【问题描述】:
我能够通过 ssl(工作)从 mongo shell 连接 mongodb: mongo --ssl --sslCAFile ca.crt --sslPEMKeyFile client.pem mongodb://xxxx:xxxx@xxxxx:27017/test_db?authSource=admin
从 rails 我无法连接我的 mongoid 配置文件如下:
development:
clients:
default:
#database: mastt_development
uri: mongodb://xxxx:xxxx@xxxxx:27017/test_db?authSource=admin
# hosts:
# - localhost:27017
options:
max_pool_size: 3
wait_queue_timeout: 300
ssl: true
ssl_cert: /home/ubuntu/client.pem
ssl_verify: true
ssl_ca_cert: /home/ubuntu/ca.crt
options:
raise_not_found_error: false
rails c
2.6.2 :001 > User.count
Traceback (most recent call last):
1: from (irb):1
Mongo::Error::NoServerAvailable (No primary server is available in cluster: #<Cluster topology=Unknown[prod-mongo-v2:27017] servers=[#<Server address=prod-mongo-v2:27017 UNKNOWN>]> with timeout=30, LT=0.015)
2.6.2 :002 > exit
MongDB 服务器日志:
2020-06-12T06:22:05.955+0000 I NETWORK [conn680] end connection xx.xx.xx.xx:55240 (0 connections now open)
2020-06-12T06:22:16.549+0000 I NETWORK [listener] connection accepted from xx.xx.xx.xx:55241 #681 (1 connection now open)
2020-06-12T06:22:16.559+0000 I NETWORK [conn681] Error receiving request from client: SSLHandshakeFailed: The server is configured to only allow SSL connections. Ending connection from 157.45.197.173:55241 (connection id: 681)
请帮忙解决这个问题
【问题讨论】:
标签: ruby-on-rails mongodb mongoid