Pylons,uWSGI和httplib给出了上游过早关闭的连接错误

时间:2013-09-20 22:06:40

标签: nginx pylons uwsgi httplib

我有一个pylons应用程序,我试图用uWSGI在NGINX后面运行。该应用程序使用httplib发出GET请求。在贴纸下进行测试时,应用程序通常会从GET请求中接收数据,但在uWSGI后面设置后,我的nginx日志中出现以下错误:

2013/09/20 21:52:07 [error] 3920#0: *10 upstream prematurely closed connection while reading response header from upstream, client: ***, server: ***.com, request: "GET /getElevation?X_Value=-105.61019897460938&Y_Value=40.24959460394122 HTTP/1.1", upstream: "uwsgi://unix:///tmp/uwsgi.maps.sock:"

这是在uwsgi日志中:

Traceback (most recent call last):
  File "/root/.virtualenvs/maps/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/cascade.py", line 117, in __call__
    v = app(environ_copy, repl_start_response)
  File "/root/.virtualenvs/maps/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/urlparser.py", line 446, in __call__
    filename = request.path_info_pop(environ)
  File "/root/.virtualenvs/maps/lib/python2.6/site-packages/Paste-1.7.5.1-py2.6.egg/paste/request.py", line 309, in path_info_pop
    environ['SCRIPT_NAME'] += '/'
KeyError: 'SCRIPT_NAME'
[pid: 3897|app: 0|req: 1/4] **** () {44 vars in 1228 bytes} [Fri Sep 20 21:52:07 2013] GET /getElevation?X_Value=-105.61097145080566&Y_Value=40.24500880734505 => generated 0 bytes in 1 msecs (HTTP/1.1 500) 0 headers in 0 bytes (0 switches on core 0)
...The work of process 3897 is done. Seeya!
worker 2 killed successfully (pid: 3897)
Respawned uWSGI worker 2 (new pid: 3925)

我认为这可能是一个超时问题,但我为uwsgi设置了以下内容:

socket-timeout = 15
http-timeout = 15
harakiri = 60

我确定我错过了uWSGI配置的内容。有人能指出我正确的方向吗?

1 个答案:

答案 0 :(得分:0)

您的app(pylons)期待SCRIPT_NAME变量:

环境['SCRIPT_NAME'] + ='/'

KeyError:'SCRIPT_NAME'

告诉nginx将其传递给uWSGI:

uwsgi_param SCRIPT_NAME "";