Note that there are some explanatory texts on larger screens.

plurals
  1. POApache sockets not closing?
    text
    copied!<p>I have a web application written using CherryPy, which is run locally on <code>127.0.0.1:4321</code>. We use mod-rewrite and mod-proxy to have Apache act as a reverse proxy; Apache also handles our SSL encryption and may eventually be used to transfer all of our static content.</p> <p>This all works just fine for small workloads. However, I recently used <code>urllib2</code> to write a stress-testing script that would simulate a workload of 100 clients. After some time, each client gets a 503 error from Apache, indicating that Apache cannot connect to <code>127.0.0.1:4321</code>. CherryPy is functioning properly, but my Apache error log reveals lines like the following:</p> <p><code>[Thu Oct 02 12:55:44 2008] [error] (OS 10048)Only one usage of each socket address (protocol/network address/port) is normally permitted. : proxy: HTTP: attempt to connect to 127.0.0.1:4321 (*) failed</code></p> <p>Googling for this error reveals that Apache has probably run out of socket file descriptors. Since I only have 100 clients running, this implies that the connections are not being closed, either between my <code>urllib2</code> connection and Apache (I am definitely calling <code>.close()</code> on the return value of <code>urlopen</code>), or between Apache and CherryPy.</p> <p>I've confirmed that my <code>urllib2</code> request is sending an HTTP <code>Connection: close</code> header, although Apache is configured with <code>KeepAlive On</code> if that matters.</p> <p>In case it matters, I'm using Python 2.5, Apache 2.2, CherryPy 3.0.3, and the server is running on Windows Server 2003.</p> <p>So what's my next step to stop this problem?</p>
 

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