EventMachine::unbind doesn't remove the channel

30 views
Skip to first unread message
Message has been deleted

heisee

unread,
Nov 26, 2008, 12:56:20 PM11/26/08
to Juggernaut for Rails, mac...@gmail.com
Hi,

consider the following scenario:
You have multiple chats on a website.

A User is in chat 1, Juggernaut is connected and
Juggernaut.show_clients_for_channel "chat_1"
returns correct data.

When the same user enters chat 2 a call to
Juggernaut.show_clients_for_channel "chat_2"
returns, that the user is in channel 2, but
Juggernaut.show_clients_for_channel "chat_1"
still sees the user still in channel 1.

The reason is, that even if EventMachine::unbind is called and a
logout_connection-POST has happened, for Juggernaut the client is
still in channel 1, because the connection for channel 1 is not
removed.

I debugged deeply into Juggernaut Server and found the best place for
this to happen is in the periodicially called method
send_logouts_after_timeout

I can't do a simple diff at the moment, since I made some more custom
modifications, so I'd like to describe the changes here:

add the line
client.connections.delete_if {|em| em.logout_timeout and Time.now
> em.logout_timeout }
after
@@clients.each do |client|
in the send_logouts_after_timeout method.
The next line
if !client.alive? and client.give_up?
can become
if !client.alive?
because all dead connections are removed anyway before
and the give_up? method is not needed any more.

That's it. Now the call to show_clients_for_channel always returns
correct channel subscriptions.

Another change I'd like to suggest is
logger.debug("Bad response from #{url.to_s}: #{resp}")
after the line
unless resp.is_a?(Net::HTTPOK)
at the end of client.rb . I got HTTP Code 302 instead of 200 and it
took me a while to figure this out, since there's no debug info about
it in the logs.

I tested it locally and will put it into production shortly (and
hope for some good luck :-)

thanks, Heiko
Message has been deleted

heisee

unread,
Nov 27, 2008, 6:19:49 AM11/27/08
to Juggernaut for Rails
Hi there,
> I tested it locally and will put it into production shortly (and
> hope for some good luck :-)

I've got it up and running in production and it seems to work fine.

Heiko Seebach

Jesse Chan-Norris

unread,
Dec 23, 2008, 4:25:28 PM12/23/08
to Juggernaut for Rails
Sorry to resurrect an old thread, but I was wondering whether this
ever made it into the release code anywhere. I'm always wary of
patching my gems on production boxes and would love to be able to
have something that Just Works.

And a related question: is there any chance of adding a gemspec file
to the github repository so I can install the gem from there?

Thanks!
> because all dead connections areremovedanyway before
> and the give_up? method isnotneeded any more.

Jesse Chan-Norris

unread,
Dec 23, 2008, 4:38:20 PM12/23/08
to Juggernaut for Rails
Ok, so I think I answered my own question. http://github.com/ripta/juggernaut_gem/tree/master
seems to have a lot more activity lately, and it solves this problem
mentioned in this thread and also has a gemspec so I can do a gem
install --source http://gems.github.com ripta-juggernaut

jcn
Reply all
Reply to author
Forward
0 new messages