# Timeout when sending over 16k of data with UTF-8 characters

**URL:** <https://www.ruby-forum.com/t/timeout-when-sending-over-16k-of-data-with-utf-8-characters/213404>\
**Category:** NGINX\
**Created:** [November 1, 2011, 6:01am UTC](https://www.ruby-forum.com/t/timeout-when-sending-over-16k-of-data-with-utf-8-characters/213404 "2011-11-01T06:01:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![luislavena](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/l/0ea827/32.png) [@luislavena](https://www.ruby-forum.com/u/luislavena)\
**Post date:** [November 1, 2011, 6:01am UTC](https://www.ruby-forum.com/t/timeout-when-sending-over-16k-of-data-with-utf-8-characters/213404/1 "2011-11-01T06:01:42Z")

</div>

I’m experiencing an issue where nginx and having a difficult time  
determining the cause. It is timing out on an HTTPS PUT (to an HTTP  
backend) when content length is greater than 16384 (per  
$content\_length) and it contains UTF-8 characters. The connection  
hangs and I get a 408 returned by nginx after 60 seconds. When I make  
the same call directly to the backend, it succeeds. Removing the UTF-8  
characters or reducing the seize to 16384 or below will both allow the  
request to succeed through nginx.

client\_body\_buffer\_size is defaulting to 8k, and using  
$request\_body\_file I’ve determined that it isn’t the use of a  
temporary file triggering the error. Are there any other configuration  
values that default to 16k?

My current nginx configuration:  
nginx: nginx version: nginx/1.0.5  
nginx: built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)  
nginx: TLS SNI support enabled  
nginx: configure arguments: --conf-path=/etc/nginx  
–prefix=/srv/nginx/1.0.5 --with-http\_ssl\_module  
–with-http\_stub\_status\_module --add-module=…/nginx-x-rid-header  
–with-ld-opt=-luuid

I also tried 1.1.6 to see if its UTF-8 patch would help, to no avail:  
nginx: nginx version: nginx/1.1.6  
nginx: built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)  
nginx: TLS SNI support enabled  
nginx: configure arguments: --conf-path=/etc/nginx  
–prefix=/tmp/nginx-1.1.6 --with-http\_ssl\_module  
–with-http\_stub\_status\_module --add-module=…/nginx-x-rid-header  
–with-ld-opt=-luuid

Successful PUT:

$status 200  
$request\_time 0.943  
$body\_bytes\_sent 16384  
$upstream\_status 200  
$upstream\_response\_time 0.216  
$request\_length 17330  
$content\_length 16384  
$request\_body\_file /srv/nginx/1.0.5/client\_body\_temp/0000000249

Failing PUT:  
$status 408  
$request\_time 60.911  
$body\_bytes\_sent -  
$upstream\_status -  
$upstream\_response\_time -  
$request\_length 17330  
$content\_length 16385  
$request\_body\_file /srv/nginx/1.0.5/client\_body\_temp/0000000250

Ideas?  
Bryan

---

<div class="post-metadata">

**Author:** ![Bryan\_McLellan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/dc4da7/32.png) [@Bryan\_McLellan](https://www.ruby-forum.com/u/Bryan_McLellan)\
**Post date:** [November 1, 2011, 7:21am UTC](https://www.ruby-forum.com/t/timeout-when-sending-over-16k-of-data-with-utf-8-characters/213404/2 "2011-11-01T07:21:52Z")

</div>

On Tue, Nov 01, 2011 at 01:00:25AM -0400, Bryan McLellan wrote:

> $request\_body\_file I’ve determined that it isn’t the use of a  
> –with-ld-opt=-luuid  
> Successful PUT:  
> Failing PUT:  
> Bryan  
> Could you create debug log:  
> [A debugging log](http://nginx.org/en/docs/debugging_log.html)

What does this module do ?  
–add-module=../nginx-x-rid-header

–  
Igor S.

---

<div class="post-metadata">

**Author:** ![Bryan\_McLellan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/dc4da7/32.png) [@Bryan\_McLellan](https://www.ruby-forum.com/u/Bryan_McLellan)\
**Post date:** [November 1, 2011, 2:14pm UTC](https://www.ruby-forum.com/t/timeout-when-sending-over-16k-of-data-with-utf-8-characters/213404/3 "2011-11-01T14:14:54Z")

</div>

On Tue, Nov 1, 2011 at 2:21 AM, Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Could you create debug log:  
> [A debugging log](http://nginx.org/en/docs/debugging_log.html)

> <https://gist.github.com/btm/1330454>

You

Ruby throws an EOFError when this occurs:

EOFError: end of file reached  
from  
/home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/protocol.rb:135:in  
`sysread' from /home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/protocol.rb:135:in `block in rbuf\_fill’  
from  
/home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/timeout.rb:52:in  
`timeout' from /home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/timeout.rb:82:in `timeout’  
from  
/home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/protocol.rb:134:in  
`rbuf_fill' from /home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/protocol.rb:116:in `readuntil’  
from  
/home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/protocol.rb:126:in  
`readline' from /home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/http.rb:2136:in `read\_status\_line’  
from  
/home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/http.rb:2125:in  
`read_new' from /home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/http.rb:1117:in `transport\_request’  
from  
/home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/http.rb:1103:in  
`request' from /home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/http.rb:1096:in `block in request’  
from  
/home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/http.rb:564:in  
`start' from /home/btm/.rvm/rubies/ruby-1.9.1-p431/lib/ruby/1.9.1/net/http.rb:1094:in `request’  
from  
/home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/rest/rest\_request.rb:84:in  
`block in call' from /home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/rest/rest_request.rb:99:in `hide\_net\_http\_bug’  
from  
/home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/rest/rest\_request.rb:83:in  
`call' from /home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/rest.rb:219:in `block in api\_request’  
from  
/home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/rest.rb:288:in  
`retriable_rest_request' from /home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/rest.rb:218:in `api\_request’  
from  
/home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/rest.rb:130:in  
`put_rest' from /home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/node.rb:626:in `save’  
from (irb):9  
from  
/home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/shef.rb:73:in  
`block in start' from /home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/shef.rb:72:in `catch’  
from  
/home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/lib/chef/shef.rb:72:in  
`start' from /home/btm/.rvm/gems/ruby-1.9.1-p431/gems/chef-0.10.4/bin/shef:34:in `\<top (required)\>’  
from /home/btm/.rvm/gems/ruby-1.9.1-p431/bin/shef:19:in `load' from /home/btm/.rvm/gems/ruby-1.9.1-p431/bin/shef:19:in `'chef \>  
quit

> What does this module do ?  
> –add-module=../nginx-x-rid-header

> **[GitHub - newobj/nginx-x-rid-header: Nginx module that adds a 'request id' header that...](https://github.com/newobj/nginx-x-rid-header)**
>
> Nginx module that adds a 'request id' header that can be used to correlate frontend and backend requests.

It adds a header line with a uuid for associating frontend and backend  
requests.

It fails without that module as well with this configuration:

nginx: nginx version: nginx/1.1.6  
nginx: built by gcc 4.4.3 (Ubuntu 4.4.3-4ubuntu5)  
nginx: TLS SNI support enabled  
nginx: configure arguments: --conf-path=/etc/nginx  
–prefix=/tmp/nginx-1.1.6 --with-http\_ssl\_module  
–with-http\_stub\_status\_module --with-debug

Bryan

---

<div class="post-metadata">

**Author:** ![Bryan\_McLellan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/dc4da7/32.png) [@Bryan\_McLellan](https://www.ruby-forum.com/u/Bryan_McLellan)\
**Post date:** [November 1, 2011, 2:56pm UTC](https://www.ruby-forum.com/t/timeout-when-sending-over-16k-of-data-with-utf-8-characters/213404/4 "2011-11-01T14:56:59Z")

</div>

Hello!

On Tue, Nov 01, 2011 at 09:13:44AM -0400, Bryan McLellan wrote:

> On Tue, Nov 1, 2011 at 2:21 AM, Igor S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Could you create debug log:  
> > [A debugging log](http://nginx.org/en/docs/debugging_log.html)
> 
> [nginx timeout (http 408) when sending unicode · GitHub](https://gist.github.com/1330454)

2011/11/01 12:44:23 [debug] 13689#0: \*129 http header: “Content-Length:  
16385”  
…  
2011/11/01 12:44:23 [debug] 13689#0: \*129 http header: “User-Agent: Chef  
Client/0.10.4 (ruby-1.9.1-p431; ohai-0.6.10; x86\_64-linux;  
+http://opscode.com)”  
…

Note: content length is 16385.

…  
2011/11/01 12:44:23 [debug] 13689#0: \*129 http read client request body  
2011/11/01 12:44:23 [debug] 13689#0: \*129 SSL\_read: -1  
2011/11/01 12:44:23 [debug] 13689#0: \*129 SSL\_get\_error: 2  
2011/11/01 12:44:23 [debug] 13689#0: \*129 http client request body recv  
-2  
2011/11/01 12:44:23 [debug] 13689#0: \*129 http client request body rest  
16385  
…  
2011/11/01 12:44:24 [debug] 13689#0: \*129 http read client request body  
2011/11/01 12:44:24 [debug] 13689#0: \*129 SSL\_read: 8192  
2011/11/01 12:44:24 [debug] 13689#0: \*129 http client request body recv  
8192  
…  
2011/11/01 12:44:24 [debug] 13689#0: \*129 SSL\_read: 8192  
2011/11/01 12:44:24 [debug] 13689#0: \*129 http client request body recv  
8192  
2011/11/01 12:44:24 [debug] 13689#0: \*129 write: 13, 0870D8E0, 8192,  
8192  
2011/11/01 12:44:24 [debug] 13689#0: \*129 SSL\_read: -1  
2011/11/01 12:44:24 [debug] 13689#0: \*129 SSL\_get\_error: 2  
2011/11/01 12:44:24 [debug] 13689#0: \*129 http client request body recv  
-2  
2011/11/01 12:44:24 [debug] 13689#0: \*129 http client request body rest  
1

Here 16384 bytes has been read from client, and one byte remains  
(“rest 1”). OpenSSL doesn’t provide any more bytes and claims it  
needs more network input (2, SSL\_ERROR\_WANT\_READ).

2011/11/01 12:44:24 [debug] 13689#0: \*129 event timer del: 12:  
1596563798  
2011/11/01 12:44:24 [debug] 13689#0: \*129 event timer add: 12:  
60000:1596564354  
2011/11/01 12:45:24 [debug] 13689#0: \*129 event timer del: 12:  
1596564354  
2011/11/01 12:45:24 [debug] 13689#0: \*129 http run request:  
“/organizations/opscode-btm/nodes/broken?”  
2011/11/01 12:45:24 [debug] 13689#0: \*129 http finalize request: 408,  
“/organizations/opscode-btm/nodes/broken?” a:1, c:1

Though client fails to provide one more byte.

For me, it looks like problem in client. It’s either calculate  
content length incorrectly or fails to properly flush ssl buffers  
on it’s side.

Maxim D.
