Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

socket.on:recieve sometimes not working #913

Closed
Hellsy22 opened this issue Jan 8, 2016 · 1 comment
Closed

socket.on:recieve sometimes not working #913

Hellsy22 opened this issue Jan 8, 2016 · 1 comment

Comments

@Hellsy22
Copy link

Hellsy22 commented Jan 8, 2016

I have my own http-client lua library. It's working well with a dev96 Aug 2015 firmware.
But with fresh firmware (tried both master and dev) I got strange bug - event "receive" never happens in module, but working if I send commands one by one with LuaLoader. Same if I tried to send all commands in one string.

One string. No output

sk=net.createConnection(net.TCP, 0); sk:on("receive", function(sck, c) print(c) end); sk:connect(80, "192.168.0.1"); sk:send("GET /192.168.0.1.lua HTTP/1.1\r\nHost: esp\r\nConnection: close\r\nAccept: */*\r\n\r\n")

Function. No output

function justatest()
   sk=net.createConnection(net.TCP, 0);
   sk:on("receive", function(sck, c) print(c) end);
   sk:connect(80, "192.168.0.1");
   sk:send("GET /192.168.0.1.lua HTTP/1.1\r\nHost: esp\r\nConnection: close\r\nAccept: */*\r\n\r\n")
end
justatest()

Two strings with 1 sec pause. Page printed

sk=net.createConnection(net.TCP, 0); sk:on("receive", function(sck, c) print(c) end); sk:connect(80, "192.168.0.1")
sk:send("GET /192.168.0.1.lua HTTP/1.1\r\nHost: esp\r\nConnection: close\r\nAccept: */*\r\n\r\n")

I tried to use "connection" event and it happend, but nothing changes.
I tried to delay script execution by tmr.alarm(...), it not helped.

@TerryE
Copy link
Collaborator

TerryE commented Jan 8, 2016

You have to do the sk:send() in an sk:on('connection', callback_fn) with SDKs after V1.0 otherwise you will attempt to do the send before you are connected. Socket I/O is async to this executing thread.

But this issue falls under #719

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants