django+uwsgi上传大文件失败

suparek
  • 211

uwsgi的log是这样的

[uwsgi-body-read] Error reading 49152 bytes. Content-Length: 14582139 consumed: 6373376 left: 8208763 message: Client closed connection
Internal Server Error: /temrule/uploadocrpdf/
Traceback (most recent call last):
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/request.py", line 331, in read
    return self._stream.read(*args, **kwargs)
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 53, in read
    result = self.buffer + self._read_limited(size - len(self.buffer))
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 41, in _read_limited
    result = self.stream.read(size)
OSError: error during read(65536) on wsgi.input

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/exception.py", line 41, in inner
    response = get_response(request)
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/base.py", line 187, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/base.py", line 185, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/home/serverend/comengine/templaterule/views/ocrpdf_views.py", line 51, in upload_ocr_pdf
    sessionid = request.POST.get('sessionid')
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 126, in _get_post
    self._load_post_and_files()
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/request.py", line 299, in _load_post_and_files
    self._post, self._files = self.parse_file_upload(self.META, data)
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/request.py", line 258, in parse_file_upload
    return parser.parse()
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/multipartparser.py", line 238, in parse
    for chunk in field_stream:
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/multipartparser.py", line 384, in __next__
    output = next(self._producer)
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/multipartparser.py", line 517, in __next__
    for bytes in stream:
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/multipartparser.py", line 384, in __next__
    output = next(self._producer)
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/multipartparser.py", line 448, in __next__
    data = self.flo.read(self.chunk_size)
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/http/request.py", line 333, in read
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 53, in read
    result = self.buffer + self._read_limited(size - len(self.buffer))
  File "/home/yangtao/miniconda3/envs/compoengine/lib/python3.6/site-packages/django/core/handlers/wsgi.py", line 41, in _read_limited
    result = self.stream.read(size)
django.http.request.UnreadablePostError: error during read(65536) on wsgi.input
Fri Jan  5 19:25:45 2018 - SIGPIPE: writing to a closed pipe/socket/fd (probably the client disconnected) on request /temrule/uploadocrpdf/ (ip 192.168.10.3) !!!
Fri Jan  5 19:25:45 2018 - uwsgi_response_write_body_do(): Broken pipe [core/writer.c line 331] during POST /temrule/uploadocrpdf/ (192.168.10.3)
OSError: write error

这是怎么回事?怎么解决?

回复
阅读 4.3k
1 个回答
✓ 已被采纳

文件大的话考虑上传到阿里云OSS,内网下行流量免费。
可以Wireshark抓包试试

宣传栏