How to load balance mongodb replica cluster I have created a mongod replica cluster of 2 nodes , mongo1 and mongo2. to load balance I have added following rule in my haproxy

listen mongo_replica_cluster
        bind *:27017
        mode tcp
        balance roundrobin
        server mongo1 10.2.0.12:27017 check inter 10s fall 3 rise 99999999
        server mongo2 10.2.0.11:27017 check backup


but if the mongo1 goes down mongo2 becomes the primary but even if mongo1 comes up mongo2 remains primary but ha redirect all traffic to mongo1 which is slave now. I want to redirect all my traffic to only the primary node.
You don't use ha-proxy. 

Every node what connects to this replica set should have mongodb://mongo1,mongo2/?replicaSet="yourRS" -connection string, what tells which nodes are on that replicaset.. String don't need always list all nodes, most of them is enough, because Application can "ask" where current primary is located.