3

我正在使用 Django + gevent-socketio + Haproxy。所有套接字功能都可以正常工作,但在后台会生成如下所示的错误。似乎 Haproxy 的套接字标头具有非常有限的属性,不包含“status_code”,因此它失败并发送错误消息。有什么线索可以让我添加 status_code 吗?也许解决方案是在 Haproxy 配置中。谢谢!

我使用 Gunicorn 服务器作为后端

Traceback (most recent call last):

  File "/home/young/.virtualenvs/test_project/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 188, in get_response
    response = middleware_method(request, response)

  File "/home/young/.virtualenvs/test_project/local/lib/python2.7/site-packages/django/middleware/common.py", line 94, in process_response
    if response.status_code == 404:

AttributeError: 'dict' object has no attribute 'status_code'


<WSGIRequest
path:/socket.io/1/xhr-polling/313746855815,
GET:<QueryDict: {u't': [u'1358323855701']}>,
POST:<QueryDict: {}>,
COOKIES:{'csrftoken': 'K7YePbx5UF5yE7sDpX98bU4fyKChooZC',
 'sessionid': 'f9806590317a86d5300a67d195a34139'},
META:{'CSRF_COOKIE': 'K7YePbx5UF5yE7sDpX98bU4fyKChooZC',
 'GATEWAY_INTERFACE': 'CGI/1.1',
 'HTTP_ACCEPT_CHARSET': 'utf-8, iso-8859-1, utf-16, *;q=0.7',
 'HTTP_ACCEPT_ENCODING': 'gzip,deflate',
 'HTTP_ACCEPT_LANGUAGE': 'en-US',
 'HTTP_COOKIE': 'sessionid=f9806590317a86d5300a67d195a34139; csrftoken=K7YePbx5UF5yE7sDpX98bU4fyKChooZC',
 'HTTP_HOST': '192.168.1.13',
 'HTTP_REFERER': 'https://192.168.1.13/dashboard/',
 'HTTP_USER_AGENT': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24',
 'HTTP_X_NETWORK_TYPE': 'WIFI',
 'PATH_INFO': u'/socket.io/1/xhr-polling/313746855815',
 'QUERY_STRING': 't=1358323855701',
 'REMOTE_ADDR': '127.0.0.1',
 'REQUEST_METHOD': 'GET',
 'SCRIPT_NAME': u'',
 'SERVER_NAME': 'ubuntu',
 'SERVER_PORT': '8001',
 'SERVER_PROTOCOL': 'HTTP/1.0',
 'SERVER_SOFTWARE': 'gevent/0.13 Python/2.7',
 'socketio': <socketio.virtsocket.Socket object at 0x27cb950>,
 'wsgi.errors': <open file '<stderr>', mode 'w' at 0x7fdc847aa270>,
 'wsgi.input': <gevent.pywsgi.Input object at 0x27cb8d0>,
 'wsgi.multiprocess': True,
 'wsgi.multithread': False,
 'wsgi.run_once': False,
 'wsgi.url_scheme': 'http',
 'wsgi.version': (1, 0)}>
4

0 回答 0