On Friday, July 18, 2014 12:01:41 AM Daniel-Constantin Mierla wrote: > You should not call m_store() if src_ip==myself -- in this way you avoid to > store notification messages that cannot be delivered. > > Why notifications are not delivered has to be troubleshooted there. Have you > tried also with UDP? > > Cheers, > Daniel > > On 17/07/14 23:46, Peter Villeneuve wrote: > Well I've been experimenting with this for hours and still no joy > :( Hair pulling continues
Peter, I'm trying to accomplish something similar, also as a new user to Kamailio and initially starting from the guide at http://kb.asipto.com/asterisk:realtime:kamailio-4.0.x-asterisk-11.3.0-astdb though I am using Asterisk 12 and Kamailio devel (built for Fedora here https://messinet.com/rpms/browser/kamailio) My goal is that Kamailio does MESSAGE processing with MSILO storage *only* for users who actually exist -- not just any username in my domain, but a user who is in the subscribers table -- there is no sense storing a message for a username who will never register to receive it. Here are the relevant blocks in my kamailio.cfg -- I've included full routing blocks so you can see how the route is laid out. I admit that I am equally not sure that this is the right way or the most efficient way to do it, but it does work with UDP, TCP, and TLS including notifications. Now that I have it "working," and understand more about routing in Kamailio, I'm likely going to consolidate duplication. For instance, since I don't want to store messages for invalid or non-existent accounts, I will probably do the if(is_subscriber("$ou", "ps_auths", "1")) and add t_on_failure("MANAGE_FAILURE"); in the request_route, etc. Perhaps 1) this will help you, and 2) others may be able to give advice on my configuration. #!define WITH_AUTH #!define WITH_MSILO #!ifdef WITH_AUTH loadmodule "auth.so" loadmodule "auth_db.so" #!ifdef WITH_IPAUTH loadmodule "permissions.so" #!endif #!endif #!ifdef WITH_MSILO loadmodule "msilo.so" #!endif #!ifdef WITH_AUTH # ----- auth_db params ----- modparam("auth_db", "calculate_ha1", yes) modparam("auth_db", "load_credentials", "") #!ifdef WITH_ASTERISK modparam("auth_db", "user_column", "username") modparam("auth_db", "domain_column", "realm") modparam("auth_db", "password_column", "password") # Workaround http://lists.sip-router.org/pipermail/sr-users/2013-August/079267.html modparam("auth_db", "load_credentials", "username") # End workaround modparam("auth_db", "db_url", DBASTURL) modparam("auth_db", "version_table", 0) #!else modparam("auth_db", "db_url", DBURL) modparam("auth_db", "password_column", "password") modparam("auth_db", "use_domain", MULTIDOMAIN) #!endif #!ifdef WITH_IPAUTH # ----- permissions params ----- modparam("permissions", "db_url", DBURL) modparam("permissions", "db_mode", 1) #!endif #!endif #!ifdef WITH_MSILO # ----- msilo params ----- modparam("msilo", "db_url", DBURL) modparam("msilo", "from_address", "sip:$r...@my-domain.com") modparam("msilo", "offline_message", "I'll get my messages when I'm back online.") modparam("msilo", "content_type_hdr", "Content-Type: text/plain\r\n") modparam("msilo", "expire_time", 604800) #!endif ####################### route[RELAY] { # enable additional event routes for forwarded requests # - serial forking, RTP relaying handling, a.s.o. if (is_method("INVITE|BYE|SUBSCRIBE|UPDATE")) { if(!t_is_set("branch_route")) t_on_branch("MANAGE_BRANCH"); } if (is_method("INVITE|SUBSCRIBE|UPDATE")) { if(!t_is_set("onreply_route")) t_on_reply("MANAGE_REPLY"); } if (is_method("INVITE")) { if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE"); } #!ifdef WITH_MSILO if (is_method("MESSAGE")) { if(!t_is_set("failure_route")) t_on_failure("MANAGE_FAILURE"); } #!endif if (!t_relay()) { sl_reply_error(); } exit; } ####################### route[REGISTRAR] { if (is_method("REGISTER")) { if(isflagset(FLT_NATS)) { setbflag(FLB_NATB); # uncomment next line to do SIP NAT pinging ## setbflag(FLB_NATSIPPING); } if (!save("location")) sl_reply_error(); #!ifdef WITH_MSILO # Ensure we aren't unregistering # Right now, CSipSimple doesn't send an Allow header with an un-REGISTER, # so Kamailio skips to checking the Contact header for expires, and appears # to ignore the fact that an Expires: 0 header is present. if($hdr(Expires) != 0) m_dump(); #!endif #!ifdef WITH_ASTERISK route(REGFWD); #!endif exit; } } ####################### route[LOCATION] { #!ifdef WITH_SPEEDDIAL # search for short dialing - 2-digit extension if($rU=~"^[0-9][0-9]$") if(sd_lookup("speed_dial")) route(SIPOUT); #!endif #!ifdef WITH_ALIASDB # search in DB-based aliases if(alias_db_lookup("dbaliases")) route(SIPOUT); #!endif #!ifdef WITH_ASTERISK if(is_method("INVITE") && (!route(FROMASTERISK))) { # if new call from out there - send to Asterisk # - non-INVITE request are routed directly by Kamailio # - traffic from Asterisk is routed also directy by Kamailio route(TOASTERISK); exit; } #!endif $avp(oexten) = $rU; if (!lookup("location")) { #!ifdef WITH_MSILO if(is_method("MESSAGE") && src_ip!=myself) { # Ensure we have a valid account for which to store MESSAGEs #!ifdef WITH_ASTERISK if(is_subscriber("$ru", "ps_auths", "1")) { #!else if(is_subscriber("$ru", "subscriber", "1")) { #!endif if(m_store("$ru")) { xlog("L_INFO", "MSILO: MESSAGE from $fu stored for offline user $ru\n"); send_reply("202", "Accepted"); } else { xlog("L_ERR", "MSILO: unable to store MESSAGE from $fu for offline user $ru\n"); send_reply("503", "Service Unavailable"); } } else { xlog("L_ERR", "MSILO: MESSAGE from $fu not stored for non-existent user $ru\n"); send_reply("404", "Not Found"); } exit; } #!endif $var(rc) = $rc; route(TOVOICEMAIL); t_newtran(); switch ($var(rc)) { case -1: case -3: send_reply("404", "Not Found"); exit; case -2: send_reply("405", "Method Not Allowed"); exit; } } # when routing via usrloc, log the missed calls also if (is_method("INVITE")) { setflag(FLT_ACCMISSED); } } ####################### route[AUTH] { #!ifdef WITH_MSILO # do not authenticate ourselves when dumping messages if(is_method("MESSAGE") && src_ip==myself) { return; } #!endif # if caller is not local subscriber, then check if it calls # a local destination, otherwise deny, not an open relay here if (from_uri!=myself && uri!=myself) { sl_send_reply("403","Not relaying"); exit; } #!ifdef WITH_AUTH #!ifdef WITH_ASTERISK # do not auth traffic from Asterisk - trusted! if(route(FROMASTERISK)) return; #!endif #!ifdef WITH_IPAUTH if((!is_method("REGISTER")) && allow_source_address()) { # source IP allowed return; } #!endif if (is_method("REGISTER") || from_uri==myself) { # authenticate requests #!ifdef WITH_ASTERISK if (!auth_check("$fd", "ps_auths", "1")) { #!else if (!auth_check("$fd", "subscriber", "1")) { #!endif auth_challenge("$fd", "0"); exit; } # user authenticated - remove auth header if(!is_method("REGISTER|PUBLISH")) consume_credentials(); } #!endif return; } ####################### failure_route[MANAGE_FAILURE] { route(NATMANAGE); if (t_is_canceled()) { exit; } #!ifdef WITH_BLOCK3XX # block call redirect based on 3xx replies. if (t_check_status("3[0-9][0-9]")) { t_reply("404","Not found"); exit; } #!endif #!ifdef WITH_MSILO # Manage MSILO transmission failures if(is_method("MESSAGE") && src_ip!=myself) { # Ensure we have a valid account for which to store MESSAGEs #!ifdef WITH_ASTERISK if(is_subscriber("$ou", "ps_auths", "1")) { #!else if(is_subscriber("$ou", "subscriber", "1")) { #!endif if (m_store("$ou")) { xlog("L_INFO", "MSILO: MESSAGE from $fu stored for unreachable user $ou\n"); send_reply("202", "Accepted"); } else { xlog("L_ERR", "MSILO: unable to store MESSAGE from $fu for unreachable user $ou\n"); send_reply("503", "Service Unavailable"); } } exit; } #!endif #!ifdef WITH_VOICEMAIL # serial forking # - route to voicemail on busy or no answer (timeout) if (t_check_status("486|408")) { $du = $null; route(TOVOICEMAIL); exit; } #!endif } -- Anthony - http://messinet.com - http://messinet.com/~amessina/gallery 8F89 5E72 8DF0 BCF0 10BE 9967 92DC 35DC B001 4A4E
signature.asc
Description: This is a digitally signed message part.
_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users