- Wed Dec 10, 2014 4:19 am
#4467
yes8s wrote:ThomasW wrote:Hi,
Maybe you get different network settings on the forwarded path than locally and the module's tcp buffer overflows (see viewtopic.php?f=18&t=642 - with slightly different symptoms). I tried your code with different filesizes - worked up to ~ 2800 btyes (which results in about 2 packets at the standard MTU of 1500) then the result was garbled. Lowering the MTU to 900 resulted in exactly what you described - no output at all (couldn't even see a response with tcpdump on the wire). I don't see a solution here besides rewriting the code to send packets line by line at the moment
Thomas
How exactly does one modify the MTU? I did want to test with a smaller packet size but I wasn't exactly sure how this would work in Lua - there is not much configuration here and the lua network api's are not exactly elaborate. Do I just issue a conn:close() inside the conn:on("receive"....) function after sending some data?
I played with the MTU on *my* side to see if I could reproduce your problem. AFAIK, there is no way to control any network settings on the lua side. It seems that we also dont have control over the sending - all we can do is set up a callback for "sent", pass a (hopefully small enough) piece of data to socket:send() and send the next chunk once we get called (hopefully) by the "sent"-event of the previous one. We can't really *wait* for the packet to be sent - from my understanding, the api just passes the data to the networking stack who builds up the packet and decides when to *actually* send it out (probably either at a full buffer or after a small timeout (which we cant't provide, alas)). Somebody please correct me if I'm wrong with this, it's just based on observations and some knowledge from working with a SPI-ethernet device some years ago.
Anyway, perhaps you can try the following with your remote connection to see if this really is the problem:
Code: Select allfunction testserver()
local srv=net.createServer(net.TCP,100)
srv:listen(80,function(conn)
conn:on("receive",function(conn,payload)
local isopen=false
conn:on("sent",function(conn)
if not isopen then
isopen = true
file.open("bigfile.html", "r")
end
local line = file.readline()
if line then
conn:send(line)
else
file.close()
conn:close()
conn=nil
end
end)
conn:send("HTTP/1.1 200 OK\r\n")
conn:send("Content-type: text/html\r\n")
conn:send("Connection: close\r\n\r\n")
end)
end)
end
testserver()
Did work over here with a reduced MTU on my side.
Thomas