Fixed NameError exception.
Added sleep to slow infinite reconnect loop.