Added connection error handling.