leafo / lapis

A web framework for Lua and OpenResty written in MoonScript
http://leafo.net/lapis/
MIT License
3.12k stars 247 forks source link

Clients with slow connections are unable to upload files #638

Closed edubart closed 3 years ago

edubart commented 6 years ago

Clients that uploads files on a slow connection cannot upload files using lapis, the server always show the error lua tcp socket read timed out

This is because as you can see at https://github.com/leafo/lapis/blob/e5dec09e3e5feef263d4eae256a6f106249effee/lapis/nginx.lua#L21 https://github.com/leafo/lapis/blob/e5dec09e3e5feef263d4eae256a6f106249effee/lapis/nginx.lua#L25 this function expects to read chunks of 8192 bytes in less than 1 second. So if the user has an upload speed lower than 8KB/s he is unable to upload because of the timeout and that situations is not uncommon, I do get a lot of these errors every day.

Please add a option to change the size of the chunk and the read timeout on file uploads.

Or increase the default read timeout value to for example 10s, while decreasing the chunk size to 4096, this would require 410bytes/s of upload speed which I find more acceptable.