added onDisconnect and removed re-connection loop.