[uwsgi-body-read] Error reading 65536 bytes. Content-Length: 560903 consumed: 0 left: 560903 message

来源:互联网 发布:免费身份证扫描软件 编辑:程序博客网 时间:2024/05/16 07:12

使用uwsgi报以上错误,原因是上传文件是,文件稍大,首先上传时间长会引起timeout,然后上传文件需要保存到uwsgi的缓冲区,缓冲区超大小,解决方法是设置两个参数.

1.socket-timeout

上传文件时接收文件的超时时间,也就是说如果你设置socket-timeout为10s, 而10s到了文件还没有上传完,就会timeout的错.
socket-timeout
argument: required_argument
shortcut: -z
parser: uwsgi_opt_set_int
help: set internal sockets timeout

2.post-buffering

argument: required_argument
parser: uwsgi_opt_set_64bit
help: enable post buffering

参数解释:
enable http body buffering. uWSGI will save to disk all HTTP body bigger than the limit specified
post-buffering = 8192
will save to disk all the HTTP body bigger than 8K. This option is required for Rack applications as they require a rewindable input stream.

3.post-buffering-bufsize

argument: required_argument
parser: uwsgi_opt_set_64bit
help: set buffer size for read() in post buffering mode

参数解释:
set the internal buffer size during post buffering (this is the memory allocated to read chunks of the socket stream)
post-buffering-bufsize 65536
will allocate 64k as the buffer for socket recv(). For a 128k body two cycle/syscall will be used.
This is a very advanced option you will probably never need to touch

Refs:
1.http://simple-is-better.com/news/301
2.http://pythonic.zoomquiet.io/data/20110523113355/index.html
3.https://github.com/unbit/uwsgi/issues/363

0 0
原创粉丝点击