Establish Connection to a xmpp server and keep it !

Hello,

(shamelessly adapted to my needs from a old message from this list)

I want to integrate status messages over xmpp in my Rails application.
My problem is that I do not want to establish a connection to the
jabber server each time a message is sent and disconnect the
connection afterwards. So I am looking for a solution to establish the
connection and use this connection in my controllers when I need it. I
am going to use xmpp4r to communicate with the jabber network.

How can I use the connection im my controllers?

Will there be some issues about multiple application instances
(because of FastCGI, Mongrel, etc.) ?

With best regards,
Mickael

Hello,

(shamelessly adapted to my needs from a old message from this list)

I want to integrate status messages over xmpp in my Rails application.
My problem is that I do not want to establish a connection to the
jabber server each time a message is sent and disconnect the
connection afterwards. So I am looking for a solution to establish the
connection and use this connection in my controllers when I need it. I
am going to use xmpp4r to communicate with the jabber network.

How can I use the connection im my controllers?

You're going to some sort of persistent process to maintain this. Call
this an xmpp daemon, it will be the process (not a mongrel or fastcgi
instance) in charge of talking to the jabber server(s).
You then need to decide how you're going to talk to this process. You
could use drb, you could have a table in the database that this
process looks at (something like a 'pending_status_updates' table),
etc....
You might also want to look at the latest version of backgroundrb, the
advantage there is that they've figured out communication etc... for
you.

Fred

Thanks Frederick for your reply, it is exactly what I needed to know
(do I have to keep the connection outside my controller, the answer is
yes).

Nathan, the post I adapted is from alexander at kueken.net
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6e054869c5e09eb1/

Thanks for your help.

I will play a bit with backgroundrb, and implement a worker to keep
xmpp connections.

Mickael.

I've taken this approach (creating an XMPP worker in BackgroundRB). In
my case, I need a proxy for many users on our sites, so this middle-
ware needs to pool many connections to jabber servers and let the
Rails app poll for data once in a while (for things like presence
updates).

BackgroundRB is going through major changes right now, but making fast
progress, so it is worth checking out and getting on the mailing list.

There have been a number of threads on this topic http://railsforum.com/
too.

If others are working on Jabber/XMPP middle layers, it would be great
to compare notes.

-chris

or source code ? :slight_smile:

Hi,

Thanks Frederick for your reply, it is exactly what I needed to know
(do I have to keep the connection outside my controller, the answer is
yes).

Nathan, the post I adapted is from alexander at kueken.net
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/6e054869c5e09eb1/

Thanks for your help.

I will play a bit with backgroundrb, and implement a worker to keep
xmpp connections.

Hey there,

With latest version of BackgrounDRb you can have tcp connections
integrated within event loop of your worker. Your worker would hold
the connection and you can pass messages to worker from rails easily.

The capability is already there, not just documented on how to have
tcp client/server connections from a bdrb worker. But this I have
rectified. Ping me on bdrb mailing list, I would be glad to help you
out on this.