No suitable servers found (`serverSelectionTryOnce` set) in mongcxx driver 3.6.1

Recently we migrate mongocxx driver from 2.2 to 3.6.1. I have got an error when connecting to a mongodb replica set. The replica set is configure with hostnames using DNS aliases (mhost1, mhost2, mhost3) rather than physical hostnames. This is because the physical hosts may change from time to time.

Our app uses physical hostnames and ports to connect to the replica set. With the legacy mongocxx 2.2, the app called mongo::DBClientReplicaSet class with physical host and port pairs and replica set name to get connection without any issue.

With mongocxx 3.6.1 , the app uses a uri constructed with physical hostnames:

mongodb://username:password@mongohost1:27027,mongohost2:27028/?authSource=dbname&replicaSet=rsname

However, the connection attempt gets an exception of No suitable servers found:

No suitable servers found (serverSelectionTryOnce set): [Failed to resolve ‘mhost1’] [Failed to resolve ‘mhost2’] [Failed to resolve ‘mhost3’]: generic server error

While mhost1/2/3 are DNS aliases from the replica set configuration on the mongodb server, the aliases are not given in the uri used by the app as above.

The unresolved DNS aliases seem a new issue in mongocxx 3.6.1. How can I tell the driver to find the physical hosts of the aliases?

Thanks.