# Nginx\_push\_stream module and X-Accel-Redirect, nginx sub-request issue?

**URL:** <https://www.ruby-forum.com/t/nginx-push-stream-module-and-x-accel-redirect-nginx-sub-request-issue/208542>\
**Category:** NGINX\
**Created:** [June 21, 2011, 3:49am UTC](https://www.ruby-forum.com/t/nginx-push-stream-module-and-x-accel-redirect-nginx-sub-request-issue/208542 "2011-06-21T03:49:42Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 21, 2011, 3:49am UTC](https://www.ruby-forum.com/t/nginx-push-stream-module-and-x-accel-redirect-nginx-sub-request-issue/208542/1 "2011-06-21T03:49:42Z")

</div>

Hi

I’m trying to use the nginx push stream module here:

> **[GitHub - wandenberg/nginx-push-stream-module: A pure stream http push...](https://github.com/wandenberg/nginx-push-stream-module/)**
>
> A pure stream http push technology for your Nginx setup. Comet made easy and really scalable. - GitHub - wandenberg/nginx-push-stream-module: A pure stream http push technology for your Nginx setup...

The general flow is that the client connects to [https://server/events/](https://server/events/),  
which internally does some auth checks on the connection, and then does  
X-Accel-Redirect to to [https://server/sub?id=\*channelname](https://server/sub?id=*channelname)\* to connect  
the push channel to the user.

Unfortunately nginx closes the connection after 5 seconds. I asked the  
module author about this, and he mentioned that he had already seen the  
issue, but it’s related to an internal nginx code design with sub  
requests which he talks about here:

[https://groups.google.com/group/nginxpushstream/msg/577fe1ffe636da75](https://groups.google.com/group/nginxpushstream/msg/577fe1ffe636da75)

Not being an expert on the code, I’m not sure where the issue is, but  
was hoping to connect people so it can be resolved 🙂

Rob  
Rob M.  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![Robert\_Mueller](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/bbce88/32.png) [@Robert\_Mueller](https://www.ruby-forum.com/u/Robert_Mueller)\
**Post date:** [July 3, 2011, 11:56pm UTC](https://www.ruby-forum.com/t/nginx-push-stream-module-and-x-accel-redirect-nginx-sub-request-issue/208542/2 "2011-07-03T23:56:43Z")

</div>

Hello!

On Tue, Jun 21, 2011 at 11:48:59AM +1000, Robert Mueller wrote:

> Unfortunately nginx closes the connection after 5 seconds. I asked the  
> module author about this, and he mentioned that he had already seen the  
> issue, but it’s related to an internal nginx code design with sub  
> requests which he talks about here:
> 
> [https://groups.google.com/group/nginxpushstream/msg/577fe1ffe636da75](https://groups.google.com/group/nginxpushstream/msg/577fe1ffe636da75)
> 
> Not being an expert on the code, I’m not sure where the issue is, but  
> was hoping to connect people so it can be resolved 🙂

(in case it’s still intresting)

This looks like the problem in push stream module from here. It  
incorrectly set r-\>discard\_body by hand[1] instead of using  
ngx\_http\_discard\_request\_body() function, and this causes  
lingering to be activated and close connection as long as there  
are no data from client within lingering\_timeout (5s by default).

[1]

> <https://github.com/wandenberg/nginx-push-stream-module/blob/master/src/ngx_http_push_stream_module_subscriber.c#L145>

Maxim D.
