Handle connection errors better.

Change-Id: Ife9e804e86da1b97d4714609e93304ef11dbff66