Add retry option in case of socket timeout

Raise exception in class instead of exit
Add a while loop to keep trying 5 times before
we exit