3

I'm trying to learn and understand how XMPP works.

As I understand it, node-xmpp-bosh is a connection manager. A connection manager is not a full blown xmpp server, but sort of acts like a proxy, and forwards the xmpp requests on to a dedicated xmpp server. This results in saving the dedicated xmpp server some of the load it would usually undertake in handling connections - Though I'm not fully sure how this results in savings, or why there's such an overhead in handling connections.

I've been provided with an OpenFire xmpp server to connect to, but this resides on a different domain to my web application. I've decided to use node-xmpp-bosh as a proxy to get around the XSS issues that would result, and this should also allow me to use websockets with a BOSH fallback for older browsers.

I'm trying to use the Strophe.js library in my client application to send the actual messages.

How do I configure node-xmpp-bosh to forward the requests on to the actual xmpp server? The documentation doesn't make this very clear, so I presume it's only forwarding requests to an xmpp server on the same machine that hosts the connection manager. Also, do I need to configure Strophe differently in order to use a connection manager, or do I simply send the request to the connection manager, and this should send it on for me.

Many thanks in advance

purpletonic
  • 1,858
  • 2
  • 18
  • 29

2 Answers2

4

The default behavior for node-xmpp-bosh is to look up the domain in your jabber id using DNS.

You can override this by providing a custom lookup service. In the example below, the lookup service will always connect to 10.10.7.245.

var server = nxb.start_bosh({
    lookup_service: MyLookupService,
    logging: "TRACE",
}) ;

function MyLookupService(port, stream)
{
    console.log("connecting") ;
    this.connect = function(socket) {
        var self = this ;

        socket.connect(5222, "10.10.7.245", function(e) {
            console.log("connected:", e) ;
            self.emit("connect",e) ;
        }) ;

        socket.once("error", function(e) {
            console.log("error connecting:", e) ;
            self.emit("error",e) ;
        }) ;
    } ;
}

This doesn't seem to be documented anywhere, but that's how you do it.

Matt DiMeo
  • 1,095
  • 8
  • 11
1

The original request from the client dictates where the connection manager will forward this connection request. If the user name is foobar@jabber.org then the connectIon manager will forward to the XMPP server at jabber.org.

dhruvbird
  • 6,061
  • 6
  • 34
  • 39