# Juggernaut hangs? Workaround?

**URL:** <https://www.ruby-forum.com/t/juggernaut-hangs-workaround/189184>\
**Category:** Rails\
**Created:** [May 26, 2010, 9:23am UTC](https://www.ruby-forum.com/t/juggernaut-hangs-workaround/189184 "2010-05-26T09:23:57Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [May 26, 2010, 9:23am UTC](https://www.ruby-forum.com/t/juggernaut-hangs-workaround/189184/1 "2010-05-26T09:23:57Z")

</div>

Hi guys

I am using Juggernaut to broker a multi party chat service. For some  
reason it seems to hang often. I have isolated the hangs to the  
following line of code:

def isloggedin?  
return !Juggernaut.show\_client(self.id).nil?  
end

where self.id is the id of the user that needs to be pushed to. When it  
hangs like this I have to restart the Juggernaut server and then the web  
server seems to snap out of it. But then the Firefox clients crash and  
the other browsers also throw up an error. (The latter is not my problem  
for the moment)

I have searched the web far and wide and cannot find any reference to  
other people experiencing similar problems, so I must assume its  
something to do with my setup (running Ruby 1.8.6 and Rails 2.3.4 in  
development mode on Windows XP with Mongrel as webserver and sqlite as  
database)

Would it be possible to somehow trap this error - ie give it .5 seconds  
to respond and if it doesnt to break out? At first I thought a simple  
loop with a sleep instruction would do the trick. But obviously not -  
the show\_client function hangs altogether, so the interpreter never even  
gets to the sleep instruction.

Please assist! I am at a loss.

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [May 26, 2010, 12:54pm UTC](https://www.ruby-forum.com/t/juggernaut-hangs-workaround/189184/2 "2010-05-26T12:54:46Z")

</div>

ok - have done some more research and I can now duplicate the problem.

if I run

(0…1000).each {|i| Juggernaut.show\_clients ; puts i }

from a fresh Juggernaut restart it crashes after 130 iterations.  
Everytime. We tried it on a Mac and it doesn’t happen. It seems to run  
out of ports or connections or something like that? Even putting a

sleep 1

in the loop doesnt make a difference - for some reason the connections  
dont get flushed.

When it hangs my computer sits at 90% cpu usage.

Any ideas? anyone?

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [May 26, 2010, 8:47pm UTC](https://www.ruby-forum.com/t/juggernaut-hangs-workaround/189184/3 "2010-05-26T20:47:01Z")

</div>

On 26 May 2010, at 12:54, Pieter H. wrote:

> sleep 1
> 
> in the loop doesnt make a difference - for some reason the connections  
> dont get flushed.
> 
> When it hangs my computer sits at 90% cpu usage.
> 
> Any ideas? anyone?

Could this be related to running an old version of Juggernaut?

[http://groups.google.com/group/Juggernaut-for-Rails/browse\_thread/thread/e6ead2f9d9a10f6d?pli=1](http://groups.google.com/group/Juggernaut-for-Rails/browse_thread/thread/e6ead2f9d9a10f6d?pli=1)

I don’t even see that show\_clients method in the latest source at

> **[GitHub - maccman/juggernaut\_plugin: Realtime Rails](https://github.com/maccman/juggernaut_plugin)**
>
> Realtime Rails. Contribute to maccman/juggernaut\_plugin development by creating an account on GitHub.

anymore.

Best regards

Peter De Berdt

---

<div class="post-metadata">

**Author:** ![hostep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/h/a88e57/32.png) [@hostep](https://www.ruby-forum.com/u/hostep)\
**Post date:** [May 28, 2010, 11:52am UTC](https://www.ruby-forum.com/t/juggernaut-hangs-workaround/189184/4 "2010-05-28T11:52:28Z")

</div>

Peter De Berdt wrote:

> Could this be related to running an old version of Juggernaut?

Hi Peter

Thanks for the suggestion. Looked into it. I am running Juggernaut 0.5.8  
on both the Vista and Mac machines. On Vista the loop freezes after 130  
iterations. On mac it didnt freeze after 10 000.

So I tried it on my older installation - Windows XP, Juggernaut 0.5.7.  
Here it runs smoothly up to 1516 iterations and then throws an error -  
Errno: ECONNREFUSED: No connection could be made because the target  
machine actively refused it.

At least its a trapable error!. If I get an error back instead of a  
freeze I can work around it without having to reset the juggernaut  
server.

So here it gets more interesting. After the error occurs it seems even a  
single Juggernaut.show\_clients gets me the error. And windows never  
recovers! Even after waiting 10 minutes. I keep on getting the error (on  
XP - with Vista I couldnt even get to this point as it just freezes)

So we tried it on the Mac. Seems better - runs up to 16000 connections  
before it crashes. After a few minutes its well again - so it seems that  
the connections do get flushed and made available to Juggernaut.

I dont know much about sockets and connections etc - any advice would  
help - we eventually would want to host our solution on any platform -  
which is why we went with Ruby on Rails.
