Improved connection error handling.