title: How to track down a Python/Django/uwsgi/nginx timeout
body: <p>I've got the following setup...</p>
  
  <ul>
  <li>nginx listens on public port 80 and proxies requests to <code>localhost:10000</code></li>
  <li>uwsgi running django site 1 listens on localhost:10000 and generates some webpages. It also makes some calls to a webservice on <code>localhost:10001</code></li>
  <li>uwsgi running django site 2 listens on <code>localhost:10001</code> and amongst other things, It makes some calls to a webservice on <code>otherhost:1234</code></li>
  </ul>
  
  <p>When <code>otherhost</code> is busy, some requests are expected to take up to 10 minutes to complete. Unfortunately, after exactly 2 minutes, nginx gives a <code>502 Bad Gateway</code>.</p>
  
  <p>As far as I can see, the problem has to be one of...</p>
  
  <h3>nginx timeout:</h3>
  
  <p>I believe this is unlikely as that would be a 504 but I'm using:</p>
  
  <pre><code>proxy_read_timeout 1800;
  proxy_connect_timeout 1800;
  </code></pre>
  
  <h3>uwsgi #1 timeout:</h3>
  
  <p>I'm launching uwsgi like this (in both cases)</p>
  
  <pre><code>nohup uwsgi --http :8000 --chdir /opt/Path/To/Project --module Project.wsgi
              --virtualenv /opt/pyenv --enable-threads --logto /var/log/LogFile.log -p 1
              --threads 50 -t 1800 2&gt; /dev/null &amp;
  </code></pre>
  
  <h3>Django site 1 calling site 2:</h3>
  
  <p>The call is being made like this:</p>
  
  <pre><code>    response = urllib.request.urlopen(Url, urlencode(Data).encode("utf-8"), 
                 timeout=1800).read().decode("utf-8")
  </code></pre>
  
  <h3>Site 2 calling othersite:</h3>
  
  <p>This is being done by a library which uses the <code>HTTPConnectionPool</code>. I've configured a timeout of 10 minutes. I think this is unlikely as setting it to (say) 2s results in an Http 500 on timeout...</p>
  
  <p>I've scanned my codebase for <code>timeout</code> (and <code>120</code>, <code>120000</code>, and even, in desperation <code>2</code>) but I can't find anywhere the timeout is being set - I assume it's a default from <em>something</em>.</p>
  
  <p>If I skip nginx and do:</p>
  
  <pre><code>curl -m1800 -XGET 'http://localhost:10000/UI/Url'
  </code></pre>
  
  <p>I get</p>
  
  <blockquote>
    <p>curl: (52) Empty reply from server</p>
  </blockquote>
  
  <p>After exactly one minute.</p>
  
  <p>Is there anything obvious that I'm missing? What's a good way to track this one down?</p>