# Keep Alive Bug

**URL:** <https://www.ruby-forum.com/t/keep-alive-bug/198556>\
**Category:** NGINX\
**Created:** [November 3, 2010, 1:49pm UTC](https://www.ruby-forum.com/t/keep-alive-bug/198556 "2010-11-03T13:49:16Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [November 3, 2010, 1:49pm UTC](https://www.ruby-forum.com/t/keep-alive-bug/198556/1 "2010-11-03T13:49:16Z")

</div>

With keep alive enabled I regularly get issues where requests are  
combined,  
it seems to depend on the status of a background XMLHTTP request as to  
whether or not they will be combined.

The output I get is like:

,{“id”:147,“user”:{“username”:“dursun123123”,“sitename”:“The Warez  
Scene”,“profile\_url”:“#”},“message”:“HELLO”,“time”:1288710293},{“id”:148,“user”:{“username”:“hacker3w0rlds”,“sitename”:“The  
Warez Scene”,“profile\_url”:“#”},“message”:“hello  
all”,“time”:1288710537},{“id”:149,“user”:{“username”:“shootie”,“sitename”:“The  
Warez  
Scene”,“profile\_url”:“#”},“message”:“ham”,“time”:1288724254},{“id”:150,“user”:{“username”:“Anonymous”,“sitename”:“The  
Warez  
Scene”,“profile\_url”:“#”},“message”:“superfly1972”,“time”:1288725995},{“id”:151,“user”:{“username”:“dursun123123”,“sitename”:“The  
Warez  
Scene”,“profile\_url”:“#”},“message”:“HELLO”,“time”:1288728745},{“id”:152,“user”:{“username”:“Anonymous”,“sitename”:“The  
Warez  
Scene”,“profile\_url”:“#”},“message”:“madsen”,“time”:1288730813},{“id”:153,“user”:{“username”:“Anonymous”,“sitename”:“The  
Warez Scene”,“profile\_url”:“#”},“message”:“RILEY  
RILEY”,“time”:1288734307},{“id”:154,“user”:{“username”:“Anonymous”,“sitename”:“The  
Warez  
Scene”,“profile\_url”:“#”},“message”:“[WalterBosque-art.com](http://WalterBosque-art.com)”,“time”:1288740171},{“id”:155,“user”:{“username”:“Anonymous”,“sitename”:“The  
Warez Scene”,“profile\_url”:“#”},“message”:“what  
up”,“time”:1288744021},{“id”:156,“user”:{“username”:“Anonymous”,“sitename”:“The  
Warez Scene”,“profile\_url”:“#”},“message”:“whats the best jenna  
presley  
scene???”,“time”:1288744066},{“id”:157,“user”:{“username”:“Anonymous”,“sitename”:“The  
Warez  
Scene”,“profile\_url”:“#”},“message”:“:D”,“time”:1288763786},{“id”:158,“user”:{“username”:“Anonymous”,“sitename”:“TWS”,“profile\_url”:“”},“message”:“drive  
mender”,“time”:1288782574},{“id”:159,“user”:{“username”:“Anonymous”,“sitename”:“TWS”,“profile\_url”:“”},“message”:“forensic”,“time”:1288783532}]HTTP/1.1  
200 OK  
Server: nginx/0.8.52  
Date: Wed, 03 Nov 2010 12:45:29 GMT  
Content-Type: text/html; charset=UTF-8  
Transfer-Encoding: chunked  
Connection: keep-alive  
X-Powered-By: PHP/5.3.3-0.dotdeb.1  
Cache-Control: private, no-cache=“set-cookie”  
Expires: 0  
Pragma: no-cache  
Content-Encoding: gzip

40b9  
��������{s�ȱ��O��X�&����K��%˖�d�X��9��jH�$D��!��I��4��Or=�%�K�N��M6���A�LOO�����w/�]���5�Ǟu���ɛ#�P,�\>ՎJ�/�\_\_��X�ݲu\*?rc7�W_�|[�  
�8��J777�7�� �.ޗnVE\>N-�\_�ڱ]8��=�=ގ=?�\_���t���v����S�`����A�`����  
�Q6?�gc’VL_����z������b\<�8+�k�;�qI����  
U9�����b�`�>'����Z/�~�kw��#Ig��[wL�8������RW�;�Љ�$����18X��Fq�vY��/�*/m�k��c��a�(OT�v�� �y��r�x*v޼l-��\d���_8����ч���;�i:�1�C�F��]�s|G�V_]��|��,�۸���%2�hk��Pg�Ѵ��x Oǡ�X��ĵ#(б^7�([S�җ��Bw��HC��$���U֞�!�s�v�������꽡���MJ�3 ��n��WcG ������X�5�r���E?�k�T2�9�$����ڎ�X`�X(9���ڕ��  
�~s�A0�’�x"�ů�P�F|섮�7&1p�k�}W0���\_  
�p�0I�;�!�%

The first is the JSON output of a shoutbox currently requesting on that  
page, the second portion is the real page.

With keepalive disabled this does not occur. Data is being fetched via  
proxy\_pass to remote host. Shoutbox is using POST requests ever 10  
seconds.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 3, 2010, 1:58pm UTC](https://www.ruby-forum.com/t/keep-alive-bug/198556/2 "2010-11-03T13:58:05Z")

</div>

Nginx don’t support chunked response from buckend.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 3, 2010, 2:33pm UTC](https://www.ruby-forum.com/t/keep-alive-bug/198556/3 "2010-11-03T14:33:19Z")

</div>

its not chunked and I believe I found the problem, the first request was  
a  
few bytes out on its Content-Length, nginx should stop reading input  
once  
this is reached and this would prevent any weird bugs from happening  
again.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 3, 2010, 2:47pm UTC](https://www.ruby-forum.com/t/keep-alive-bug/198556/4 "2010-11-03T14:47:46Z")

</div>

You request:

X-Powered-By: PHP/5.3.3-0.dotdeb.1  
Cache-Control: private, no-cache=“set-cookie”  
Expires: 0  
Pragma: no-cache  
Content-Encoding: gzip

40b9  
^^^^

is a length of chunk, right?

On Wed, Nov 3, 2010 at 16:32, SplitIce [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> its not chunked and I believe I found the problem, the first request was a few  
> bytes out on its Content-Length, nginx should stop reading input once this is  
> reached and this would prevent any weird bugs from happening again.

–  
wbr, Kirill

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 3, 2010, 3:12pm UTC](https://www.ruby-forum.com/t/keep-alive-bug/198556/5 "2010-11-03T15:12:16Z")

</div>

Hello!

On Wed, Nov 03, 2010 at 04:46:29PM +0300, Kirill A. Korinskiy wrote:

> is a length of chunk, right?

Kirill, it’s nginx reply as seen on client, not backend’s one.

Maxim D.

p.s. Please do not top-post. Thank you.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [November 3, 2010, 2:45pm UTC](https://www.ruby-forum.com/t/keep-alive-bug/198556/6 "2010-11-03T14:45:16Z")

</div>

Hello!

On Wed, Nov 03, 2010 at 11:47:50PM +1100, SplitIce wrote:

> Warez  
> Scene",“profile\_url”:“#”},“message”:“ham”,“time”:1288724254},{“id”:150,“user”:{“username”:“Anonymous”,“sitename”:“The  
> Warez  
> Scene”,“profile\_url”:“#”},“message”:“:D”,“time”:1288763786},{“id”:158,“user”:{“username”:“Anonymous”,“sitename”:“TWS”,“profile\_url”:“”},“message”:"drive  
> Pragma: no-cache
> 
> The first is the JSON output of a shoutbox currently requesting on that  
> page, the second portion is the real page.
> 
> With keepalive disabled this does not occur. Data is being fetched via  
> proxy\_pass to remote host. Shoutbox is using POST requests ever 10 seconds.

If you are able to reproduce the problem - you may want to provide  
more info, i.e. what happens on wire (use tcpdump/wireshark/etc)  
between client and nginx, as well as nginx -V output, config and  
debug log.

See here for more info:

> **[GitHub - nginxinc/nginx-wiki: ARCHIVED -- Source for the now archived NGINX Wiki...](https://github.com/nginxinc/nginx-wiki)**
>
> ARCHIVED -- Source for the now archived NGINX Wiki section of https://www.nginx.com

Note well: there are some known bugs which may introduce protocol  
breakage and cause wierd effects on kept alive connections. Most  
frequently mentioned one is related to caching of 0-sized replies  
from backend without Content-Length set. See here for patches:

> **[\[PATCH 0 of 2\] cache fixes for empty and stale responses](http://mailman.nginx.org/pipermail/nginx-devel/2010-January/000100.html)**

> **[\[PATCH 1 of 2\] Cache: fix sending of empty](http://mailman.nginx.org/pipermail/nginx-devel/2010-January/000101.html)**

> **[\[PATCH 2 of 2\] Cache: fix sending of stale responses](http://mailman.nginx.org/pipermail/nginx-devel/2010-January/000102.html)**

Maxim D.
