Added a timeout for trying to connect to a server