【问题标题】:deploying flask application using gunicorn throws OSError: [Errno 0] Error使用 gunicorn 部署烧瓶应用程序会引发 OSError:[Errno 0] 错误
【发布时间】:2021-06-30 13:32:28
【问题描述】:

使用 gunicorn 部署烧瓶应用程序每次都会抛出 OSError: [Errno 0] Error

以下是错误:

[2021-06-28 12:00:21 +0000] [11] [ERROR] Socket error processing request.
Traceback (most recent call last):
File "/usr/local/lib/python3.8/dist-packages/gunicorn/workers/sync.py", line 135, in handle
req = next(parser)
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/parser.py", line 42, in __next__
self.mesg = self.mesg_class(self.cfg, self.unreader, self.source_addr, self.req_count)
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/message.py", line 180, in __init__
super().__init__(cfg, unreader, peer_addr)
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/message.py", line 54, in __init__
unused = self.parse(self.unreader)
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/message.py", line 192, in parse
self.get_data(unreader, buf, stop=True)
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/message.py", line 183, in get_data
data = unreader.read()
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/unreader.py", line 37, in read
d = self.chunk()
File "/usr/local/lib/python3.8/dist-packages/gunicorn/http/unreader.py", line 64, in chunk
return self.sock.recv(self.mxchunk)
File "/usr/lib/python3.8/ssl.py", line 1226, in recv
return self.read(buflen)
File "/usr/lib/python3.8/ssl.py", line 1101, in read
return self._sslobj.read(len)
OSError: [Errno 0] Error

环境详情:

Python 版本:Python 3.8.5

guncorn 模块版本:20.0.4

gunicorn 配置文件:

"""Gunicorn configurations."""
import os

bind = "0.0.0.0:443"
workers = os.cpu_count() - 1
keyfile = "/home/xyz/certs/psa_xyz.key"
certfile = "/home/xyz/certs/psa_xyz.crt"
timeout = 120

【问题讨论】:

    标签: python-3.x flask gunicorn


    【解决方案1】:

    另一个应用程序已经在使用该端口,或者您有防火墙问题阻止您访问该端口。要确认这一点,您可以尝试将端口更改为 5000。

    所以你的配置应该是这样的。

    """Gunicorn configurations."""
    import os
    
    bind = "0.0.0.0:5000"
    workers = os.cpu_count() - 1
    keyfile = "/home/xyz/certs/psa_xyz.key"
    certfile = "/home/xyz/certs/psa_xyz.crt"
    timeout = 120
    

    【讨论】:

      猜你喜欢
      • 2020-08-30
      • 2016-03-19
      • 1970-01-01
      • 2020-10-12
      • 2019-01-25
      • 1970-01-01
      • 2012-08-03
      • 1970-01-01
      • 2023-04-02
      相关资源
      最近更新 更多