python-3.x - 使用 gunicorn 部署烧瓶应用程序会引发 OSError:[Errno 0] 错误
问题描述
每次使用 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
解决方案
另一个应用程序已经在使用该端口,或者您有防火墙问题阻止您访问该端口。要确认这一点,您可以尝试将端口更改为 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
推荐阅读
- git - Jenkinsfile,获取PR中所有修改过的文件
- jquery - jquery控制的多级html菜单
- ironpython - 是否可以使用 IronPython 的 scapy 脚本?
- apache-flink - Flink 中的动态 SQL 查询
- java - 如何等待从 GUI 输入回到主界面?
- kubernetes - 如何在不提及其名称的情况下将自定义 yaml 文件传递给 helm
- react-native - react-native 中如何优雅的管理图片资源?
- linux - 对使用 Yocto 安装 -m 和安装 -d 感到困惑
- c# - 如何显示从控制器中的 viewbag 传递的数据以查看
- amazon-cloudformation - AWS CLI : Windows CLI -- SSLError: [Errno 2] No such file or directory