title: PANIC: unprotected error in call to Lua API (stdin:8: attempt to call global 'run' (a nil value))
body: <p>Using NodeMCU from <a href="https://github.com/nodemcu/nodemcu-firmware" rel="nofollow">https://github.com/nodemcu/nodemcu-firmware</a> running the following code: </p>
  
  <pre><code>ssid = "www.mydomain.com"
  pass = "234234234432"
  
  
  gpio.write(0, gpio.LOW)
  
  print("Startup up wifi mode")
  
  wifi.setmode(wifi.STATION)
  wifi.sta.config(ssid, pass)
  
  wifi.sta.autoconnect(1)
  wifi.sta.connect()
  
  
  tmr.alarm(3, 1000, 1, function() 
      if (wifi.sta.status() &lt; 5) then
          print("Connecting...")        
      else 
          tmr.stop(3)
          print("Connected having IP "..wifi.sta.getip())
          gpio.write(0, gpio.HIGH)        
          run()      
      end
  end)
  
  gpio.write(0, gpio.HIGH)
  
  
  
  
  function run() 
      print("run")
  
      myhost="www.adafruit.com"
      mypage="testwifi/index.html"
      myip=""
  
      sk=net.createConnection(net.TCP, 0)
      sk:dns(myhost,function(conn,ip) 
      myip=ip
      sk=net.createConnection(net.TCP, 0)
      sk:on("receive", function(sck, c) print(c) end )
      sk:connect(80,myip)
      sk:send("GET / " .. mypage .." HTTP/1.1\r\nHost: " .. myhost .."\r\nConnection: keep-alive\r\nAccept: */*\r\n\r\n")
      sk=nil
  
  
  end
  </code></pre>
  
  <p>I got this error: </p>
  
  <pre><code>PANIC: unprotected error in call to Lua API (stdin:8: attempt to call global 'run' (a nil value))
  ����m������!������!�1���
  Waiting answer from ESP - Timeout reached. Command aborted.
  </code></pre>
  
  <p><strong>How do I resolve this?</strong></p>