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

On 12 Dec 2007, at 09:43, MickTaiwan wrote:

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

I don’t know if I am the lucky post you adapted but I posted something
similar a while back. I am still working on that project now. I am using
XMPP4R to communicate with a Jabber server we are running. It is a rails
application and I am using Drb to communicate with the Jabber server
persistently. It works pretty well. Feel free to email me - xgamerx10
(at) gmail (dot) com if you have any specific questions or want to talk
about it.

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

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.

Hi,

Dec 13, 2007 2:57 AM, MickTaiwan [email protected] wrote:

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.


Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.

http://gnufied.org

On Dec 13, 8:11 am, chaupt [email protected] wrote:

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

or source code ? :slight_smile:

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs