Use rpc endpoint if it exists.

This will let our API nodes not to talk to public ip address for better latency and security.