Move connection failed listener into a separate class.