【问题标题】:Socket error processing request with flask, gunicorn, docker and azure使用烧瓶、gunicorn、docker 和 azure 处理套接字错误请求
【发布时间】:2019-01-08 05:09:19
【问题描述】:

使用 gunicorn 运行 python 烧瓶应用程序。当我在本地启动 docker 镜像时,一切都很好,但是当我使用 kubernetes 在 azure 上运行 docker 镜像时,我得到了这个 OSError。请求正常,但在日志中出现错误。

有人现在发生了什么吗?

10.242.0.1 - - [31/Jul/2018:15:11:04 +0000] "GET /api/evaluation HTTP/1.1" 200 14343  "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"
[2018-07-31 15:11:05 +0000] [10] [ERROR] Socket error processing request.
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/gunicorn/workers/sync.py", line 134, in handle
    req = six.next(parser)
  File "/usr/local/lib/python3.6/site-packages/gunicorn/http/parser.py", line 41, in __next__
    self.mesg = self.mesg_class(self.cfg, self.unreader, self.req_count)
  File "/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py", line 181, in __init__
    super(Request, self).__init__(cfg, unreader)
  File "/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py", line 54, in __init__
    unused = self.parse(self.unreader)
  File "/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py", line 193, in parse
    self.get_data(unreader, buf, stop=True)
  File "/usr/local/lib/python3.6/site-packages/gunicorn/http/message.py", line 184, in get_data
    data = unreader.read()
  File "/usr/local/lib/python3.6/site-packages/gunicorn/http/unreader.py", line 38, in read
    d = self.chunk()
  File "/usr/local/lib/python3.6/site-packages/gunicorn/http/unreader.py", line 65, in chunk
    return self.sock.recv(self.mxchunk)
  File "/usr/local/lib/python3.6/ssl.py", line 994, in recv
    return self.read(buflen)
  File "/usr/local/lib/python3.6/ssl.py", line 871, in read
    return self._sslobj.read(len, buffer)
  File "/usr/local/lib/python3.6/ssl.py", line 633, in read
    v = self._sslobj.read(len)
OSError: [Errno 0] Error

启动应用程序

gunicorn --certfile Config/cert.crt --keyfile Config/cert.key -w 2 -b :8084 --access-logfile - gunicorn_app:app

【问题讨论】:

  • 你能解决这个问题吗?我遇到了同样的错误。
  • 没有。但是更多信息在这里github.com/benoitc/gunicorn/issues/1885。在那里添加了一个问题,因为我在这里没有答案

标签: python azure docker flask gunicorn


【解决方案1】:

最后发现是pod liveness probes造成的,因为gunicorn服务器目前不能同时支持http和https,如果我们只使用https作为公共域,http probes check request会失败这个错误。

解决方案: 将 gunicorn 服务器更改为 Nginx 或 Apache。

【讨论】:

    【解决方案2】:

    将python版本从3.6.*升级到3.7.4,效果很好。

    【讨论】:

    • 目前在 3.7.5 上仍然遇到这个错误。
    【解决方案3】:

    我已经从gunicorn变成了uwsgi,不再头疼了!!!

    【讨论】:

    • 您可能是指其他令人头疼的问题,例如缺乏文档
    猜你喜欢
    • 2020-10-07
    • 2018-08-29
    • 1970-01-01
    • 2017-06-02
    • 2018-05-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多