Implement lost connection handler and automatic reconnect in the Demo.