reconnect automatically when reconnect option is true otherwise raise an exception