Fixed isConnected bug when an exception is thrown on connect.