Do not try connection to api server indefinitely. Give up after 10 retries.

Change-Id: I892daa6d5d663063ec59f7d53545acfef6769e67
Closes-Bug: 1372656