'NodeMCU net server listen gives error out of memory in lua (esplorer)

I have one error here that I don't know how to solve and didn't find a working solution on the Internet.

I have a NodeMCU 12 E. and I want to transfer data from an Android app to my board. But first I want to set my nodemcu as a Wi-Fi soft access point and as a server, so the phone can connect to it and send a message. I explored documentation and copy-pasted an example for setting up a socket server and receiving data.

And it gives error "out of memory" in the line where it says "srv:listen(port,function...)" (code below).

*Note: there's nothing in my nodemcu.

I've tried to erase all data and reinstall firmware as I found in one website (I forgot where), but it didn't help.

print("Setting up Wi-Fi...")
wifi.setmode(wifi.SOFTAP)
wifi.ap.config({ ssid = "NodeMCU BABY", pwd = "Password" })
print("Server IP Address:", wifi.ap.getip())

port = 12345

--modify according your wireless router settings
--wifi.sta.config("xxx", "xxx")
--wifi.sta.connect()
sv = net.createServer(net.TCP, 30)

function receiver(sck, data)
  print("Recieved data : ")
  print(data)
  --sck:close()
end

if sv then
  print("Server created successfully...")

    sv:listen(port, function(conn)
      conn:on("receive", receiver)
      --conn:send("hello world")
    end)

end
end

Yes, I edited code a bit to make it softAC. But in theory it should work the same.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source