implement auto reconnect use sleep and synchronized