<div dir="ltr">Hello,<div><br></div><div>I'm just guessing here, but it sounds like the connection is closed before the headers are sent. This is a common problem unrelated to nginx (unless your module has some sort of serious performance issue elsewhere). This is especially common for requests generated by mobile clients who's networks are often unavailable. </div><div><br>The thing that stands out to me is your conditional to catch errors is very similar to the conditional used in ngx_http_request.c, hoever, it's missing NGX_HTTP_CLIENT_CLOSED_REQUEST. If this is the case, your condition is satisfied because NGX_HTTP_CLIENT_CLOSED_REQUEST is > NGX_OK. I recommend you amend your logging to include more information about why the request has failed.<br><br>If you find that NGX_HTTP_CLIENT_CLOSED_REQUEST is<span style="color:rgb(51,51,51);font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:12px;line-height:18.6667px;white-space:pre"> returned, I would look for culprits elsewhere. Perhaps the load is greater than the server/kernels link speed? </span><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Sep 24, 2015 at 2:18 AM, Hung Nguyen <span dir="ltr"><<a href="mailto:hungnv@opensource.com.vn" target="_blank">hungnv@opensource.com.vn</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hello, <div><br></div><div>In my module I do something like this:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span style="white-space:pre-wrap"> </span>nlog->action = "sending file to client";</div><div><div> r->headers_out.status = NGX_HTTP_OK;</div></div><div><div> r->headers_out.content_length_n = bucket->content_length;</div></div><div><div> r->headers_out.last_modified_time = of.mtime;</div></div><div><div> r->headers_out.content_type.len = sizeof ("text/html") - 1;</div></div><div><div> r->headers_out.content_type.data = (u_char *) "text/html";</div></div><div><div> rc = ngx_http_send_header(r);</div></div><div><div> if (rc == NGX_ERROR || rc > NGX_OK || r->header_only) {</div></div><div><div> ngx_log_error(NGX_LOG_ALERT, nlog, ngx_errno, ngx_close_file_n "ngx_http_send_header failed");</div></div><div><div> return rc;</div></div><div><div> }</div></div></blockquote><div><br></div><div><br></div><div>it’s ok when traffic is low, but when there are many user request to nginx, error log is full of these similar errors:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><span lang="EN-US" style="font-family:Consolas;font-size:14px">2015/09/17 08:57:16 [alert] 9915#0: *5205 close()ngx_http_send_header failed while sending file to client, client: 127.0.0.1, server: my.local, request: "GET /slides/128553.pdf?secl=LMz1w4xNwd9pt_88-ROxkw§=1442496276 HTTP/1.0", host: “<a href="http://kvazar.china-cdn88nmbwacdnln8hq8qwe.com" style="color:purple" target="_blank">m</a><a href="http://y.server.com" target="_blank">y.server.com</a>", referrer: "</span><a href="http://uakino.net/uppod.swf" style="color:purple;font-family:Consolas;font-size:14px" target="_blank"><span lang="EN-US">http://my.server.com/uppod.swf</span></a><span lang="EN-US" style="font-family:Consolas;font-size:14px">”</span></div></blockquote><div><span lang="EN-US" style="font-family:Consolas;font-size:14px"><br></span></div><div><span lang="EN-US" style="font-family:Consolas;font-size:14px"><br></span></div><div><br></div><div>Is this a normal behavior, or there much be something wrong in my module cause nginx cannot send header to client? </div><div><br></div><div><br></div><div>Thanks,</div><div><br></div><div>Hưng</div><div><br></div></div><br>_______________________________________________<br>
nginx-devel mailing list<br>
<a href="mailto:nginx-devel@nginx.org">nginx-devel@nginx.org</a><br>
<a href="http://mailman.nginx.org/mailman/listinfo/nginx-devel" rel="noreferrer" target="_blank">http://mailman.nginx.org/mailman/listinfo/nginx-devel</a><br></blockquote></div><br></div>