Fix NameError when not connected