fix line 1672 error and handle socket connect exception error