imporve connection error handling.
fix incorrect escape