[OpenSIPS-Users] pua_xmpp sip-xmpp gateway setup help

mani sivaraman mani.opensips at gmail.com
Thu Jun 18 17:56:26 CEST 2009


I'm new to opensips. I'm trying to setup sip-xmpp gateway using the
"component" mode with a local ejabbered server. I followed the opensips.cfg
found in link

http://www.opensips.org/Resources/PuaXmppConfig

I have 3 domains defined for my opensips server.

sips01.mydomain.com     - primary opensips dns/domain defined in my sql
doamin table
sip-xmpp.mydoamin.com - for gateway sip domain
xmpp.mydomain.com      - for xmpp server
xmpp-sip.mydomain.com - for xmpp component of opensips

I have configured the same according to the link. config above.

I have all these 4 domain in /etc/hosts file. The first primary domain is
the only one on dns look up.

I have ejabbered server listenening on port 5347, I also see my opensips
ESTABLISHED connetion to port 5347 of ejabbered.

Testing:
------------
I logged into opensips with a sip/presence client and added an xmpp buddy to
the sip contact list with the following format. The xmpp buddy is on an
openfire server.
so the buddy added was like

mani_openfire*openfire.mydomain.com at sip-xmpp.mydomain.com

I see opensips sending SUBSCRIBE to mani_openfire and got NOTIFY for the
same. But there is no body in the NOTIFY. Says subscription state = active.
I do not see any communication to the openfire server however, if I do a
tcpdump.

When I try to send a message to the openfire buddy, I get 200 OK, but the
MESSAGE never gets through to the openfire server buddy.

I'm attaching the opensips.cfg for ref. Could any one please point out what
I'm doing wrong. I do not seeing any error when testing. Still MESSAGE is
not working bet sip and xmpp.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.opensips.org/pipermail/users/attachments/20090618/a1d7ab7a/attachment.htm 
-------------- next part --------------

#
# $Id: opensips.cfg 5503 2009-03-22 16:22:32Z bogdan_iancu $
#
# OpenSIPS basic configuration script
#     by Anca Vamanu <anca at voice-system.ro>
#
# Please refer to the Core CookBook at:
#      http://www.opensips.org/index.php?n=Resources.DocsCookbooks
# for a explanation of possible statements, functions and parameters.
#


####### Global Parameters #########

debug=3
log_stderror=no
log_facility=LOG_LOCAL0

fork=yes
children=4

/* uncomment the following lines to enable debugging */
#debug=6
#fork=no
log_stderror=yes

/* uncomment the next line to disable TCP (default on) */
#disable_tcp=yes

/* uncomment the next line to enable the auto temporary blacklisting of
   not available destinations (default disabled) */
#disable_dns_blacklist=no

/* uncomment the next line to enable IPv6 lookup after IPv4 dns
   lookup failures (default disabled) */
#dns_try_ipv6=yes

/* uncomment the next line to disable the auto discovery of local aliases
   based on revers DNS on IPs (default on) */
#auto_aliases=no

/* uncomment the following lines to enable TLS support  (default off) */
#disable_tls = no
#listen = tls:your_IP:5061
#tls_verify_server = 1
#tls_verify_client = 1
#tls_require_client_certificate = 0
#tls_method = TLSv1
#tls_certificate = "/usr/local/etc/opensips/tls/user/user-cert.pem"
#tls_private_key = "/usr/local/etc/opensips/tls/user/user-privkey.pem"
#tls_ca_list = "/usr/local/etc/opensips/tls/user/user-calist.pem"

port=5060

/* uncomment and configure the following line if you want opensips to
   bind on a specific interface/port/proto (default bind on all available) */
listen=udp:172.16.0.139:5060
alias=sips01.smithmicro.com


####### Modules Section ########

#set module path
mpath="/usr/local/lib/opensips/modules/"

/* uncomment next line for MySQL DB support */
loadmodule "db_mysql.so"
loadmodule "signaling.so"
loadmodule "sl.so"
loadmodule "tm.so"
loadmodule "rr.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "mi_fifo.so"
loadmodule "uri_db.so"
loadmodule "uri.so"
loadmodule "xlog.so"
loadmodule "acc.so"
#loadmodule "purple.so"
/* uncomment next lines for MySQL based authentication support
   NOTE: a DB (like db_mysql) module must be also loaded */
loadmodule "auth.so"
loadmodule "auth_db.so"
/* uncomment next line for aliases support
   NOTE: a DB (like db_mysql) module must be also loaded */
loadmodule "alias_db.so"
/* uncomment next line for multi-domain support
   NOTE: a DB (like db_mysql) module must be also loaded
   NOTE: be sure and enable multi-domain support in all used modules
         (see "multi-module params" section ) */
#loadmodule "domain.so"
/* uncomment the next two lines for presence server support
   NOTE: a DB (like db_mysql) module must be also loaded */
loadmodule "presence.so"
loadmodule "presence_xml.so"
loadmodule "pua.so"
loadmodule "xmpp.so"
loadmodule "pua_xmpp.so"

# ----------------- setting module-specific parameters ---------------


# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")


# ----- rr params -----
# add value to ;lr param to cope with most of the UAs
modparam("rr", "enable_full_lr", 1)
# do not append from tag to the RR (no need for this script)
modparam("rr", "append_fromtag", 0)


# ----- registrar params -----
modparam("registrar", "method_filtering", 1)
/* uncomment the next line to disable parallel forking via location */
# modparam("registrar", "append_branches", 0)
/* uncomment the next line not to allow more than 10 contacts per AOR */
#modparam("registrar", "max_contacts", 10)


# ----- usrloc params -----
modparam("usrloc", "db_mode",   0)
/* uncomment the following lines if you want to enable DB persistency
   for location entries */
modparam("usrloc", "db_mode",   2)
modparam("usrloc", "db_url",
        "mysql://opensips:opensipsrw@172.16.0.139/opensips")

# ---- purple params -----
#modparam("purple", "db_url", "mysql://opensips:opensipsrw@172.16.0.139/opensips")
#modparam("purple", "db_table", "purplemap")
#modparam("purple", "httpProxy_host", "10.26.52.12")
#modparam("purple", "httpProxy_port", 3128)


# ----- uri_db params -----
/* by default we disable the DB support in the module as we do not need it
   in this configuration */
modparam("uri_db", "use_uri_table", 0)
modparam("uri_db", "db_url", "")


# ----- acc params -----
/* what sepcial events should be accounted ? */
modparam("acc", "early_media", 1)
modparam("acc", "report_ack", 1)
modparam("acc", "report_cancels", 1)
/* by default ww do not adjust the direct of the sequential requests.
   if you enable this parameter, be sure the enable "append_fromtag"
   in "rr" module */
modparam("acc", "detect_direction", 0)
/* account triggers (flags) */
modparam("acc", "failed_transaction_flag", 3)
modparam("acc", "log_flag", 1)
modparam("acc", "log_missed_flag", 2)
/* uncomment the following lines to enable DB accounting also */
modparam("acc", "db_flag", 1)
modparam("acc", "db_missed_flag", 2)


# ----- auth_db params -----
/* uncomment the following lines if you want to enable the DB based
   authentication */
modparam("auth_db", "calculate_ha1", no)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "db_url",
        "mysql://opensips:opensipsrw@172.16.0.139/opensips")
modparam("auth_db", "load_credentials", "")


# ----- alias_db params -----
/* uncomment the following lines if you want to enable the DB based
   aliases */
modparam("alias_db", "db_url",
        "mysql://opensips:opensipsrw@172.16.0.139/opensips")


# ----- domain params -----
/* uncomment the following lines to enable multi-domain detection
   support */
#modparam("domain", "db_url",
#       "mysql://opensips:opensipsrw@172.16.0.139/opensips")
#modparam("domain", "db_mode", 1)   # Use caching


# ----- multi-module params -----
/* uncomment the following line if you want to enable multi-domain support
   in the modules (dafault off) */
#modparam("alias_db|auth_db|usrloc|uri_db", "use_domain", 1)


# ----- presence params -----
/* uncomment the following lines if you want to enable presence */
modparam("presence|presence_xml", "db_url",
        "mysql://opensips:opensipsrw@172.16.0.139/opensips")
modparam("presence_xml", "force_active", 1)
modparam("presence", "server_address", "sip:172.16.0.139:5060")

# -- pua and pua_xmpp params -- # new params mani added
modparam("pua", "db_url", "mysql://opensips:opensipsrw@172.16.0.139/opensips")
modparam("pua_xmpp", "server_address", "sip:172.16.0.139:5060")

# -- xmpp parameters -- # new params mani added
modparam("xmpp", "backend", "component")
modparam("xmpp", "domain_separator", "*")
modparam("xmpp", "gateway_domain", "sip-xmpp.smithmicro.com")
modparam("xmpp", "xmpp_domain", "xmpp-sip.smithmicro.com")
modparam("xmpp", "xmpp_host", "xmpp.smithmicro.com")
modparam("xmpp", "xmpp_password", "smsi123")

####### Routing Logic ########

# main request routing logic

route{

        # initial sanity checks -- messages with
        # max_forwards==0, or excessively long requests
        if (!mf_process_maxfwd_header("10")) {
                sl_send_reply("483","Too Many Hops");
                exit;
        };

        #if (msg:len >=  2048 ) {
        #       sl_send_reply("513", "Message too big");
        #       exit;
        #};

        # we record-route all messages -- to make sure that
        # subsequent messages will go through our proxy; that's
        # particularly good if upstream and downstream entities
        # use different transport protocol
        if (!method=="REGISTER")
                record_route();

        # subsequent messages withing a dialog should take the
        # path determined by record-routing
        if (loose_route()) {
                # mark routing logic in request
                append_hf("P-hint: rr-enforced\r\n");
                route(1);
        };
        if(method == "INVITE")
                setflag(5);

        if( uri=~"sip:.+ at sip-xmpp.smithmicro.com" ||
                 uri=~"sip:.+ at sip-xmpp.smithmicro.com" ||
                 uri=~"sip:.+ at sips01.smithmicro.com")
        {
                if( is_method("PUBLISH|SUBSCRIBE|NOTIFY"))
                        route(2);
        }

        if( uri=~"sip:.+ at sip-xmpp.smithmicro.com")
        {
                # absorb retransmissions ###
                if (!t_newtran()) {
                        sl_reply_error();
                        return;
                }
        if (method == "MESSAGE") {
                        log("*** xmpp-handled MESSAGE message.\n");
                        if (xmpp_send_message()) {
                                t_reply("200", "Accepted");
                        } else {
                                t_reply("404", "Not found");
                        }
                        return;
                }else {
                        t_reply("403","not supported");
                        exit;
                }

        }

        if (!uri==myself) {
                # mark routing logic in request
                append_hf("P-hint: outbound\r\n");
                # if you have some interdomain connections via TLS
                #if(uri=~"@tls_domain1.net") {
                #       t_relay("tls:domain1.net");
                #       exit;
                #} else if(uri=~"@tls_domain2.net") {
                #       t_relay("tls:domain2.net");
                #       exit;
                #}
                route(1);
        };

        # if the request is for other domain use UsrLoc
        # (in case, it does not work, use the following command
        # with proper names and addresses in it)
        if (uri==myself) {

                if( is_method("PUBLISH|SUBSCRIBE|NOTIFY"))
                        route(2);

                if (method=="REGISTER") {

                        if (!www_authorize("", "subscriber"))
                        {
                                www_challenge("", "0");
                                exit;
                        }

                        if (!check_to())
                        {
                                sl_send_reply("403","Forbidden auth ID");
                                exit;
                        }

                        if (!save("location"))
                                sl_reply_error();

                        exit;
                };

                # native SIP destinations are handled using our USRLOC DB
                if (!lookup("location")) {
                        sl_send_reply("404", "Not Found");
                        exit;
                };
                append_hf("P-hint: usrloc applied\r\n");
        };

        route(1);
}


route[1] {
        # send it out now; use stateful forwarding as it works reliably
        # even for UDP2TCP
        if (!t_relay()) {
                sl_reply_error();
        };
        exit;
}

route[2]
{
        if ( !t_newtran() ){
        sl_reply_error();
        exit;
     };

        if( is_method("NOTIFY") && uri=~"sip:.+ at sip-xmpp.smithmicro.com"){
                pua_xmpp_notify();
                t_reply("200", "OK");
                exit;
        }

        if(is_method("PUBLISH")){
                handle_publish();
                #t_release();
                /* the call to t_release is no longer needed in 1.5 */
        }
        else
        if( is_method("SUBSCRIBE")){
                handle_subscribe();
                if( uri=~"sip:.+ at sip-xmpp.smithmicro.com" && $hdr(Event)== "presence"){
                        pua_xmpp_req_winfo("$ruri", "$hdr(Expires)");
                }
                #t_release();
                /* the call to t_release is no longer needed in 1.5 */
        }

        exit;
}



More information about the Users mailing list