<div dir="ltr">Hi,<br><div class="gmail_quote"><div dir="ltr"><div><br></div><div>I know this appeared some time ago with first versions of SPDY, but we have been using 1.4.1 SPDY in production and it is generating lots of CLOSE_WAIT connections.</div>
<div><br></div>
<div>Doing some testing, I found reproducible steps and a possible patch.</div><div><br></div><div>Our env (listing what I think are relevant points, please ask for more if you need it):</div><div>1. Nginx 1.4.1</div><div>
2. SSL + SPDY</div><div>3. Proxy-pass 443 port to a Rails app</div><div>3. Sendfile on</div><div><br></div><div>Steps to reproduce:</div><div>1. Perform a POST with a big body (I'm uploading a file)</div><div>2. Refresh the browser before the upload finishes</div>
<div>3. Close the browser</div><div><br></div><div>When the connection is closed due the browser close, the error.log (with debug enabled) says:</div><div><div><b>2013/09/10 10:02:53 [info] 4372#0:</b> *12 client closed prematurely connection while processing SPDY, client: 1.2.3.4, server: <a href="http://0.0.0.0:443" target="_blank">0.0.0.0:443</a></div>
<div><b>2013/09/10 10:02:53 [debug] 4372#0:</b> *12 http reading blocked</div></div><div><br></div><div>And nothing else happens.</div><div><br></div><div>I tried to add a connection check inside <b>ngx_http_block_reading </b>based on <b>ngx_http_test_reading:</b></div>
<blockquote class="gmail_quote" style="margin:0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;border-right-width:1px;border-right-color:rgb(204,204,204);border-right-style:solid;padding-left:1ex;padding-right:1ex">
</blockquote><div><br></div>#if (NGX_HTTP_SPDY)<br><br> if (r->spdy_stream) {<br><br> if (c->error) {<br> err = 0;<br><br> goto closed;<br> }<br><br> return;<br> }<br>
#endif<br><div><br></div><div>I'm checking if the spdy_stream is open before trying to read from it. It converts the CLOSE_WAIT connections to TIME_WAIT and they do finalize after some seconds.</div><div><br></div><div>
I dig into nginx code yesterday, so I'm far from correctly understand where the real problem is, but this "patch" seems reasonable to me.</div><div><br></div><div>Can someone with better nginx source code understanding, provide some feedback?</div>
<div><br></div><div>And thanks for all your work!</div>
</div>
</div><br></div>