Out of memory on srv:listen

时间:2018-11-05 22:40:22

标签: lua esp8266 nodemcu

I searched all the web but didn't find an answer. I want to set up a wifi AP and a webserver on the NodeMCU.

I use the following code:

wifi.setmode(wifi.STATIONAP)
wifi.ap.config({ ssid = "test", pwd = "12345678" })
print("Server IP Address:", wifi.ap.getip())

srv = net.createServer(net.TCP)
srv:listen(80, function(conn)
    conn:on("receive", function(sck, request)
        print("received: " .. request)
        sck:send("echo: " .. request)
    end)
end)

This is what I get after uploading:

> dofile("init.lua");
Server IP Address:  192.168.1.1 255.255.255.0   192.168.1.1
init.lua:6: out of memory
stack traceback:
    [C]: in function 'listen'
    init.lua:6: in main chunk
    [C]: in function 'dofile'
    stdin:1: in main chunk

The firmware I use:

NodeMCU custom build by frightanic.com
    branch: master
    commit: c708828bbe853764b9de58fb8113a70f5a24002d
    SSL: false
    modules: file,gpio,net,node,tmr,uart,wifi
 build created on 2018-11-05 22:20
 powered by Lua 5.1.4 on SDK 2.2.1(6ab97e9)

Any clues on how to get it working?

0 个答案:

没有答案