# HTTP push module - how to use

**URL:** <https://www.ruby-forum.com/t/http-push-module-how-to-use/188025>\
**Category:** NGINX\
**Created:** [May 4, 2010, 12:06pm UTC](https://www.ruby-forum.com/t/http-push-module-how-to-use/188025 "2010-05-04T12:06:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![dcian](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/91b2a8/32.png) [@dcian](https://www.ruby-forum.com/u/dcian)\
**Post date:** [May 4, 2010, 12:06pm UTC](https://www.ruby-forum.com/t/http-push-module-how-to-use/188025/1 "2010-05-04T12:06:12Z")

</div>

Hi,

I saw the HTTP push module and it looks like it might be ideal for my  
purposes, but I am not clear how best to use it. (Linux nubie).

It seems that I set up the module and configure it to have a /publish  
and /subscribe url - each using ?id= parameter, so we can have  
more than one push stream at a time.

The javascript in the clients then use XMLHttpRequest to GET from the  
subscribe URL. When the reply arrives, it acts upon what arrived, and  
immediately issues the next GET.

Each client will also have a form which POSTs to another URL - lets call  
this chat.php that will  
a) Authenticate that this client may speak 🙂  
b) Filtering - not those words, but recognising requests for info,  
fetched on demand.  
c) Do Logging,  
d) Use the cURL library to POST what should be published to the  
/publish URL  
e) Return an empty 200 reply (so the page is not replaced).

I’ve had trouble in the past with Apache timing out long running  
processes after 600 seconds. Do I need some sort of heartbeat to avoid  
these problems?

The browser will time-out the subscribe request after a while. If there  
is nothing broadcast for a while and the HTTP stack times out then  
(IIRC) no event is called which means Javscript cannot re-issue the  
subscribe. How can I code round this?

My customer wants the clients to see when someone starts to type. This  
could be a message sent when the first character is entered into the  
input box. When it arrives the javascript will alter the icon  
representing that person. Sounds OK. Would it be fast enough?

My startup page must read the log and include all the history in the  
initial page. So I will have to pass message numbers (or timestamps?)  
through from the log to the initial page, to the first subscribe  
request. I am not clear what to pass to the subscribe URL to get the  
right messages. Note - some messages, such as the “typing” update, are  
not logged!

Using this module would be a major departure from the current design (  
“long polling”, with a timeout of 4 seconds), but could be MUCH more  
scalable.

Comments and advice welcome.

Regards

Ian
