Catch IOException when the master does not exist in order to throw better error message.
Add a handler to close the socket