到特定端点的GET请求导致Python Flask服务器崩溃:

 请允许我的每一天有你_248 发布于 2023-02-08 05:23

所有,

我有一个使用Flask构建的具有两个端点的API。我正在使用nginx / uwsgi组合来提供服务,每当我向端点之一发送GET请求时,我都会收到一个奇怪的错误。另一个端点工作正常。

这是来自get请求的uwsgi日志的输出

File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1646, in request_context
    return RequestContext(self, environ)
File "/usr/local/lib/python2.7/dist-packages/flask/ctx.py", line 166, in __init__
    self.url_adapter = app.create_url_adapter(self.request)
File "/usr/local/lib/python2.7/dist-packages/flask/app.py", line 1475, in create_url_adapter
    server_name=self.config['SERVER_NAME'])
File "/usr/local/lib/python2.7/dist-packages/werkzeug/routing.py", line 1196, in bind_to_environ
    environ['REQUEST_METHOD'], environ.get('PATH_INFO'),
KeyError: 'REQUEST_METHOD'

并且,这是来自get请求的nginx错误日志的输出

2013/12/26 15:22:16 [error] 833#0: *9 upstream prematurely closed connection while reading response header from upstream, 
client: 71.71.53.31, server: scholarly, 
request: "GET /citelet/ HTTP/1.1", 
upstream: "uwsgi://unix:///tmp/citelet.sock:", 
host: "162.243.219.38"

对于这个问题的含糊之处,我深表歉意。我已经在相同的硬件,相同的库上多次设置了该服务器,并且之前没有任何问题。错误令人困惑,我不确定从哪里开始寻找。

提前致谢!

1 个回答
  • 愚蠢的错误。我的nginx配置出现错误。它指向一个不存在的套接字。

    server {
        listen   80;
              server_name scholarly;
          # crowdscholar endpoint
            location /crowdscholar {
                uwsgi_pass unix:///tmp/crowdscholar.sock;
            include uwsgi_params;
            # strip path before handing it to app
            uwsgi_param SCRIPT_NAME /crowdscholar;
            uwsgi_modifier1 30;
        }
        # citelet endpoint
            location /citelet {
                uwsgi_pass unix:///tmp/citelet.sock;
            include uwsgi_params;
            # strip path before handing it to app
            uwsgi_param SCRIPT_NAME /citelet;
            uwsgi_modifier1 30;
        }
    }
    

    2023-02-08 05:45 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有