UnknownHostException while connecting to mongodb using mongo spark connector and multiple hosts

rishabh 1 Reputation point
2022-07-20T12:25:12.203+00:00

As the title says,
Using : spark.read.format("com.mongodb.spark.sql.DefaultSource") \
.option("uri", connectionString) \
.load()

to load data from mongo. It works like a charm when I use only 1 host but when hosts are>1 then it throws:

com.mongodb.MongoTimeoutException: Timed out after 30000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate

Please help

Azure Data Share
Azure Data Share
An Azure service that is used to share data from multiple sources with other organizations.
45 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
9,643 questions
{count} votes