zhjx922 / lua-upload

openresty file chunk upload
3 stars 2 forks source link

上传大文件时,经常会出现lua tcp socket read timed out, #1

Open bryant24 opened 7 years ago

bryant24 commented 7 years ago

你好,文件分片的最后一片上传完后,该合并了,很大几率会出现这个错误: [error] 7379#7379: *228 lua tcp socket read timed out... 结果是合并失败了,已经设置NGINX lua_socket_read_timeout 1h,还是不行 location /file_upload { lua_socket_read_timeout 3600s; client_max_body_size 10G; default_type text/html; content_by_lua_file lua/upload.lua; }

zhjx922 commented 7 years ago

@bryant24 首先,我这个代码是玩具。然后说原因:io是阻塞的,因为分片多合并时间久就会出现这个问题,你可以参考迅雷下载的原理,先通过上传文件的总大小生成一个空文件,然后分片上传的时候按对应的偏移量位置写入即可。

zhjx922 commented 5 years ago

你好,文件分片的最后一片上传完后,该合并了,很大几率会出现这个错误: [error] 7379#7379: *228 lua tcp socket read timed out... 结果是合并失败了,已经设置NGINX lua_socket_read_timeout 1h,还是不行 location /file_upload { lua_socket_read_timeout 3600s; client_max_body_size 10G; default_type text/html; content_by_lua_file lua/upload.lua; }

还有一个方法,文件就分片传,最后也不合并,读取的时候一片一片依次读。

javacty commented 4 years ago

合并分片可以放到ngx.timer.at里执行,不会有超时问题,测试可用,不过合并完成后不知道怎么通知前台……