fix loop / handling error when connecting fails immediately