Discover nodes from ES client

I have a java ES client connects to a pre configured IP.
Typically ES runs @port 9200. But when the master node is down, another node is elected as the master but it runs @port 9201.

Is there a way for ES client to discover the master nodes port ?
Or should I try ports starting from 9200 and up.