It looks like the isConnected() function also tries to connect.  That is a little weird because the name isFoo just sounds like a getter function which does not actually do any work.