/**
     * Connection failed callback.
     *
     * @param errorMsg smack failure message
     */
    public void connectionFailed(String errorMsg) {
      Log.d(TAG, "Connection Failed");
      final int n = mRemoteConnListeners.beginBroadcast();

      for (int i = 0; i < n; i++) {
        IBeemConnectionListener listener = mRemoteConnListeners.getBroadcastItem(i);
        try {
          if (listener != null) listener.connectionFailed(errorMsg);
        } catch (RemoteException e) {
          // The RemoteCallbackList will take care of removing the
          // dead listeners.
          Log.w(TAG, "Error while triggering remote connection listeners", e);
        }
      }
      mRemoteConnListeners.finishBroadcast();
      mService.stopSelf();
      resetApplication();
    }