Resolved a bug in reconnection logic on onclose side.