Note that there are some explanatory texts on larger screens.

plurals
  1. PO502 Bad Gateway on WSGI app using Nginx + Cherrypy
    primarykey
    data
    text
    <p>I have a Python application served via CherryPy's WSGI server, receiving requests from Nginx. It's hosted on a Windows Server 2003 box, and there are only a few users accessing it.</p> <p>Sometimes, requests to a specific resource fail almost instantly with a <strong>502 Bad Gateway</strong> on Firefox. I've tried to reproduce the problem on other browsers, without success.</p> <p>The application is started like this:</p> <pre><code>paths = { "/resource": resource_func } dispatcher = wsgiserver.WSGIPathInfoDispatcher(paths) server = wsgiserver.CherryPyWSGIServer(("127.0.0.1", 9191), dispatcher) server.start() </code></pre> <p>The nginx server is forwarding requests to CherryPy via <code>proxy_pass</code>:</p> <pre><code>location / { proxy_pass http://127.0.0.1:9191/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } </code></pre> <p>The requests are sent via jQuery.ajax method:</p> <pre><code>$.ajax(requestURI).done(myRequestCallback); </code></pre> <p>If I run Firebug, then open nginx error log when a 502 occurs, I see the following error:</p> <pre><code>(time): *92 WSASend() failed (10054: An existing connection was forcibly closed by the remote host) while sending request to upstream, client: xxx.xxx.xxx.xxx, server: localhost, request: "GET /resource?params=VALUES&amp;_=1371674388573 HTTP/1.1", upstream: "http://127.0.0.1:9191/resource?params=VALUES&amp;_=1371674388573", host: "xxx.xxx.xxx.xxx:9080", referrer: "http://172.27.129.112:9080/myAppPage.html" </code></pre> <p>... where <code>xxx.xxx.xxx.xxx</code> is the IP from which I'm testing the application, and nginx is listening to <code>9080</code>.</p> <p>The failing requests do not show up in our app's log file, and the same resource and params are valid (a request does not fail on every attempt).</p> <p>I've even added the following lines to my nginx.conf file (then restarted both servers) to try to fix the problem, but it didn't seem to make ay difference:</p> <pre><code>proxy_buffers 8 16k; proxy_buffer_size 32k; </code></pre> <p>The versions are:</p> <ul> <li>Firefox 21</li> <li>Python 2.7.5</li> <li>nginx 1.2.0</li> <li>CherryPy 3.2.2</li> </ul> <p>What could be causing the error?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload