gpt4 book ai didi

python - 我如何配置我的 uWsgi 服务器以防止不可读的发布错误?

转载 作者:太空狗 更新时间:2023-10-29 18:09:22 30 4
gpt4 key购买 nike

问题是:

  File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/six.py", line 535, in next
return type(self).__next__(self)
File "/app/.heroku/python/lib/python2.7/site-packages/django/http/multipartparser.py", line 344, in __next__
output = next(self._producer)
File "/app/.heroku/python/lib/python2.7/site-packages/django/utils/six.py", line 535, in next
return type(self).__next__(self)
File "/app/.heroku/python/lib/python2.7/site-packages/django/http/multipartparser.py", line 406, in __next__
data = self.flo.read(self.chunk_size)
File "/app/.heroku/python/lib/python2.7/site-packages/django/http/request.py", line 267, in read
six.reraise(UnreadablePostError, UnreadablePostError(*e.args), sys.exc_info()[2])
File "/app/.heroku/python/lib/python2.7/site-packages/django/http/request.py", line 265, in read
return self._stream.read(*args, **kwargs)
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 59, in read
result = self.buffer + self._read_limited(size - len(self.buffer))
File "/app/.heroku/python/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 47, in _read_limited
result = self.stream.read(size)
UnreadablePostError: error during read(65536) on wsgi.input

我当前的配置是这样的:

[uwsgi]
http-socket = :$(PORT)
master = true
processes = 4
die-on-term = true
module = app.wsgi:application
memory-report = true
chunked-input-limit = 25000000
chunked-input-timeout = 300
socket-timeout = 300

Python: 2.7.x | uWsgi: 2.0.10

为了使问题更加具体,当我在上传图片的同时同步处理图片时,就会发生这种情况。我知道理想情况下我必须使用 Celery 执行此操作,但由于业务需求我无法执行此操作。因此需要以允许我接受大图像文件、处理它然后返回响应的方式配置超时。

对这个问题的任何解释都会非常有帮助。谢谢。

最佳答案

描述中引用的错误并非全貌;相关部分是这批条目:

[uwsgi-body-read] Error reading 65536 bytes … message: Client closed connection uwsgi_response_write_body_do() TIMEOUT

这个特定的错误被引发是因为(很可能)客户端,或者它和 uWSGI 之间的某个东西,中止了请求。

造成这种情况的可能原因有很多:

  • 有问题的客户端
  • 网络级过滤(DPI 或一些配置错误的防火墙)
  • uWSGI 前面的服务器中的错误/错误配置

最后一个包含在the uWSGI docs中:

If you plan to put uWSGI behind a proxy/router be sure it supports chunked input requests (or generally raw HTTP requests).

要验证您的问题确实不在 uWSGI 中,请尝试通过托管您的 uWSGI 应用程序的服务器上的控制台上传文件。直接访问 HTTP 端点,绕过 nginx/haproxy 和 friend 。

关于python - 我如何配置我的 uWsgi 服务器以防止不可读的发布错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34402993/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com