Closed aliabbasrizvi closed 3 years ago
Figured out. Closing.
Hey @aliabbasrizvi I am having the same issue. Could you post here how to managed to resolve it please.
I create the server as
CREATE SERVER mongo_server
FOREIGN DATA WRAPPER mongo_fdw
OPTIONS (address '*****.mongodb.net', replica_set 'replica_set_here', port '27017');
and I see the error as
ERROR: could not connect to server mongo_server
Hint: Mongo error: "No suitable servers found (`serverSelectionTryOnce` set): [Failed to resolve ***.mongodb.net']"
@guns2410 I do not recall the exact resolution but I think it was a case of updating Postgres for me.
Looking at the code for the mongo wrapper
This library doesn't user the +svr
mongo protocol for handling clusters with a unified address. From altas when getting the connection information make sure to select a version < 3.0.0.
Then your options should look something like
ALTER SERVER my_mongo_fdw_server
OPTIONS (SET address 'xxx-shard-00-00.xxx.mongodb.net:27017,xxx-shard-00-01.xxx.mongodb.net:27017,xxx-00-02.xxx.mongodb.net:27017', SET replica_set 'the_replica_set', SET ssl 'true', SET authentication_database 'admin');
Hi
I am trying to connect to Atlas Mongo DB cluster and running into connection issues. Could it be that I am defining the address incorrectly when creating the server. My command looks like:
CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address 'cluster_name.mongodb.net')
I get the following error on trying to SELECT from a foreign table I define:
When I create a server with the protocol, the command looks like:
CREATE SERVER mongo_server FOREIGN DATA WRAPPER mongo_fdw OPTIONS (address 'mongodb+srv://cluster_name.mongodb.net')
I get the following error on trying to SELECT from a foreign table I define:
Please let me know if there are examples of how to connect to Atlas Mongo.
Thanks