Add reconnect and the test case
Fix the reconnecting flag not set correctly