Added connection time out, so that it doesn't indefinitely tries to connect to a server.