# Real-time message passing to browser in Rails?

**URL:** <https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277>\
**Category:** Rails\
**Created:** [January 24, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277 "2007-01-24T21:22:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![nate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nate](https://www.ruby-forum.com/u/nate)\
**Post date:** [January 24, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277/1 "2007-01-24T21:22:37Z")

</div>

Has anyone had any success getting “realtime” message passed to the  
browser in Rails? I’m wondering if there’s a helper or Prototype  
snippet that can help pass messages to a “status” window.

Basically, I have an app that is doing system tasks, like running  
command-line scripts and tailing logfiles. I want to show the output in  
near-realtime, similar to what a user would see in a command-line  
terminal window. Any ideas?

Thanks,  
Nate W.  
[dangerrabbit.com](http://dangerrabbit.com)

---

<div class="post-metadata">

**Author:** ![nate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nate](https://www.ruby-forum.com/u/nate)\
**Post date:** [January 24, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277/2 "2007-01-24T21:27:37Z")

</div>

Haven’t used it personally, but it sounds like you want Comet…

> **[Purchase Intent Data for Enterprise Tech Sales and Marketing | TechTarget](https://www.techtarget.com/)**
>
> Identify, influence and engage active buyers in your tech market with TechTarget's purchase intent insight-powered solutions. Activity matters.

On 1/24/07, Nate [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Thanks,  
> Nate W.  
> [dangerrabbit.com](http://dangerrabbit.com)
> 
> >

## –

## seth at subimage interactive

## [http://www.subimage.com](http://www.subimage.com) [http://sublog.subimage.com](http://sublog.subimage.com)

> **[Freelance Time Tracking Software — Online Invoice Software](https://cashboardapp.com/)**
>
> Freelance time tracking software, online invoice software & project management.
> Used by thousands worldwide since 2007. FREE trial.

[http://dev.subimage.com/projects/substruct](http://dev.subimage.com/projects/substruct)

---

<div class="post-metadata">

**Author:** ![nate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nate](https://www.ruby-forum.com/u/nate)\
**Post date:** [January 24, 2007, 9:27pm UTC](https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277/3 "2007-01-24T21:27:37Z")

</div>

Nate wrote:

> Has anyone had any success getting “realtime” message passed to the  
> browser in Rails? I’m wondering if there’s a helper or Prototype  
> snippet that can help pass messages to a “status” window.

Here’s my How To Chat post:

[http://www.forbiddenweb.org/topic/130997/index.html](http://www.forbiddenweb.org/topic/130997/index.html)

GMail reputedly chats by leaving the HTTP socket open. I wouldn’t  
tweak my server (and the prototype Ajax objects) just for a Status  
panel.

Use periodically\_call\_remote to repeatedly call the status action on  
the server. That’s slow, and high-bandwidth, but completely stable. My  
Chat post tells generally how.

Tip: Have one periodically\_call\_remote per page, and let it update  
anything that needs updating, via render :update.

–  
Phlip  
[http://c2.com/cgi/wiki?ZeekLand](http://c2.com/cgi/wiki?ZeekLand) ← NOT a blog!!

---

<div class="post-metadata">

**Author:** ![nate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nate](https://www.ruby-forum.com/u/nate)\
**Post date:** [January 24, 2007, 10:50pm UTC](https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277/4 "2007-01-24T22:50:51Z")

</div>

Awesome, very nice, detailed chat post, thanks!

---

<div class="post-metadata">

**Author:** ![nate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nate](https://www.ruby-forum.com/u/nate)\
**Post date:** [January 25, 2007, 3:00am UTC](https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277/5 "2007-01-25T03:00:23Z")

</div>

On 1/24/07, Nate [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Has anyone had any success getting “realtime” message passed to the  
> browser in Rails? I’m wondering if there’s a helper or Prototype  
> snippet that can help pass messages to a “status” window.
> 
> Basically, I have an app that is doing system tasks, like running  
> command-line scripts and tailing logfiles. I want to show the output in  
> near-realtime, similar to what a user would see in a command-line  
> terminal window. Any ideas?

If you happen to be using lighttpd…  
[http://www.refwell.com/blog/index.php/2007/01/25/full-dulpex-ajax-module-for-lighttpd/](http://www.refwell.com/blog/index.php/2007/01/25/full-dulpex-ajax-module-for-lighttpd/)

–  
Rick O.  
[http://weblog.techno-weenie.net](http://weblog.techno-weenie.net)  
[http://mephistoblog.com](http://mephistoblog.com)

---

<div class="post-metadata">

**Author:** ![nate](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/e95f7d/32.png) [@nate](https://www.ruby-forum.com/u/nate)\
**Post date:** [January 25, 2007, 7:31pm UTC](https://www.ruby-forum.com/t/real-time-message-passing-to-browser-in-rails/83277/6 "2007-01-25T19:31:36Z")

</div>

Just a little thing to keep in mind:

Keeping network sockets open can quickly saturate your server’s  
network stack and degrade performance to the point where no new  
connections are accepted and the server grinds to a halt.

I am not sure what your user base is, but if you are expecting it to  
be in the thousands, all connected with open sockets, then you should  
really check what the upper socket limits for your server’s network  
stack are.

At the very least you should kill inactive sockets after a timeout. I  
have not used either of the solutions mentioned in the replies but it  
is highly likely that the have an idle timeout setting.

-christos
