Python 使用flask、gunicorn、docker和azure处理请求时发生套接字错误

Python 使用flask、gunicorn、docker和azure处理请求时发生套接字错误,python,azure,docker,flask,gunicorn,Python,Azure,Docker,Flask,Gunicorn,使用gunicorn运行python flask应用程序。当我在本地旋转docker映像时,一切都很好,但是当我在azure上使用kubernetes运行docker映像时,我得到了这个操作错误。请求正常,但日志中出现错误 有人知道发生了什么吗 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 1

使用gunicorn运行python flask应用程序。当我在本地旋转docker映像时,一切都很好,但是当我在azure上使用kubernetes运行docker映像时,我得到了这个操作错误。请求正常,但日志中出现错误

有人知道发生了什么吗

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

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

最后,我发现这是由pod liveness Probe造成的,因为gunicorn服务器目前无法同时支持http和https,如果我们只对公共域使用https,http Probe检查请求将失败,并出现此错误

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

我已将gunicorn更改为uwsgi,不再令人头痛

你能解决这个问题吗?我也犯了同样的错误。但是这里有更多的信息。在那里添加了一个问题,因为我在3.7.5上没有得到答案,仍然遇到这个错误。