Sammy Govind | 1 Jan 2012 15:13
Picon

Re: [SR-Users] Intermittent start up issue

Hi,

forget the whole list of errors and just resolve the DB connectivity between the Kamailio server and DB server first .

27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
connect to MySQL server on 'xxxxxxxxx' (4) 

try connecting to the remote DB server 'xxxxxxxxx' from linux shell i.e

# mysql -u<user> -p<passwd> -h 'xxxxxxxxx'

Regards,
Sammy


On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad <ali.jawad-kFViwpaZTe3k1uMJSBkQmQ@public.gmane.org> wrote:
Hi All
I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is
that Kamailio at times fails to start up for no obvious reasons, I.e.
in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug
log "level 2 " shows the following :

27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
connect to MySQL server on 'xxxxxxxxx' (4)
27(24762) ERROR: <core> [db.c:303]: could not add connection to the
pool27(24762) ERROR: group [group.c:211]: unable to connect to the
database
27(24762) ERROR: <core> [sr_module.c:889]: init_mod_child(): Error
while initializing module group
(/usr/local/kamailio/lib/kamailio/modules_k/group.so)
27(24762) ERROR: <core> [pt.c:481]: ERROR: fork_tcp_process():
init_child failed for process 27, pid 24762, "tcp receiver child=1"

and then


30(24765) : <core> [pass_fd.c:293]: ERROR: receive_fd: EOF on 45
 0(24735) ALERT: <core> [main.c:748]: child process 24762 exited
normally, status=255
 0(24735) INFO: <core> [main.c:766]: INFO: terminating due to SIGCHLD

The problem happens on 4 different servers, I did try to compile more
than once, the servers are 32 Bit CentOS 5.6. The connection to the
database is monitored and there are no issues with connecting to the
DB "it works at times and times not for Kamailio so a user/pwd issue
is not likely to cause this, manual cnnect worked", config file errors
are not found.

I did also check max no of connections on MySQL server which is set to
500 on the server and only 100 cons are used. The group module uses
the same connection string as other modules  which is predefined  and
there are other modules that access the db before the group module and
those do not have a problem.

Please advice.

Regards

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users-cR8azDVoa3IcDhw6gZKtMeG/Ez6ZCGd0@public.gmane.orgorg
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

<div>
<p>Hi,</p>
<div>forget the whole list of errors and just resolve the DB connectivity between the Kamailio server and DB server first .</div>
<div><br></div>
<div>
<blockquote class="gmail_quote">
<span>27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't<br></span><span>connect to MySQL server on 'xxxxxxxxx' (4)</span>&nbsp;</blockquote>
<div><br></div>try connecting to the remote DB server&nbsp;<span>'xxxxxxxxx' from linux shell i.e</span>
</div>
<div><span><br></span></div>
<div>
<span># mysql -u&lt;user&gt; -p&lt;passwd&gt; -h&nbsp;</span><span>'xxxxxxxxx'</span>
</div>
<div><span><br></span></div>
<div>Regards,</div>
<div>Sammy</div>
<div><br></div>
<div>
<br><div class="gmail_quote">On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad <span dir="ltr">&lt;<a href="mailto:ali.jawad@...">ali.jawad@...</a>&gt;</span> wrote:<br><blockquote class="gmail_quote">
Hi All<br>
I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is<br>
that Kamailio at times fails to&nbsp;start up&nbsp;for no obvious reasons, I.e.<br>
in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug<br>
log "level 2 " shows the following :<br><br>
27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't<br>
connect to MySQL server on 'xxxxxxxxx' (4)<br>
27(24762) ERROR: &lt;core&gt; [db.c:303]: could not add connection to the<br>
pool27(24762) ERROR: group [group.c:211]: unable to connect to the<br>
database<br>
27(24762) ERROR: &lt;core&gt; [sr_module.c:889]: init_mod_child(): Error<br>
while initializing module group<br>
(/usr/local/kamailio/lib/kamailio/modules_k/group.so)<br>
27(24762) ERROR: &lt;core&gt; [pt.c:481]: ERROR: fork_tcp_process():<br>
init_child failed for process 27, pid 24762, "tcp receiver child=1"<br><br>
and then<br><br><br>
30(24765) : &lt;core&gt; [pass_fd.c:293]: ERROR: receive_fd: EOF on 45<br>
&nbsp;0(24735) ALERT: &lt;core&gt; [main.c:748]: child process 24762 exited<br>
normally, status=255<br>
&nbsp;0(24735) INFO: &lt;core&gt; [main.c:766]: INFO: terminating due to SIGCHLD<br><br>
The problem happens on 4 different servers, I did try to compile more<br>
than once, the servers are 32 Bit CentOS 5.6. The connection to the<br>
database is monitored and there are no issues with connecting to the<br>
DB "it works at times and times not for Kamailio so a user/pwd issue<br>
is not likely to cause this, manual cnnect worked", config file errors<br>
are not found.<br><br>
I did also check max no of connections on MySQL server which is set to<br>
500 on the server and only 100&nbsp;cons&nbsp;are used. The group module uses<br>
the same connection string as other modules &nbsp;which is predefined &nbsp;and<br>
there are other modules that access the db before the group module and<br>
those do not have a problem.<br><br>
Please advice.<br><br>
Regards<br><br>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br><a href="mailto:sr-users@...">sr-users@...org</a><br><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</blockquote>
</div>
<br>
</div>
</div>
Ali Jawad | 1 Jan 2012 18:06

Re: [SR-Users] Intermittent start up issue

Hi
Thanks for your input, but as said this works at times yes and times
now so I am not sure it is a definite DB issue, the servers are in the
same LAN, and there are other modules that use the DB string that work
when launched before this one while this one does not work.
Regards

On Sun, Jan 1, 2012 at 4:13 PM, Sammy Govind <govoiper@...> wrote:
> Hi,
> forget the whole list of errors and just resolve the DB connectivity between
> the Kamailio server and DB server first .
>
>> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> connect to MySQL server on 'xxxxxxxxx' (4)
>
>
> try connecting to the remote DB server 'xxxxxxxxx' from linux shell i.e
>
> # mysql -u<user> -p<passwd> -h 'xxxxxxxxx'
>
> Regards,
> Sammy
>
>
> On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad <ali.jawad@...> wrote:
>>
>> Hi All
>> I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is
>> that Kamailio at times fails to start up for no obvious reasons, I.e.
>> in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug
>> log "level 2 " shows the following :
>>
>> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> connect to MySQL server on 'xxxxxxxxx' (4)
>> 27(24762) ERROR: <core> [db.c:303]: could not add connection to the
>> pool27(24762) ERROR: group [group.c:211]: unable to connect to the
>> database
>> 27(24762) ERROR: <core> [sr_module.c:889]: init_mod_child(): Error
>> while initializing module group
>> (/usr/local/kamailio/lib/kamailio/modules_k/group.so)
>> 27(24762) ERROR: <core> [pt.c:481]: ERROR: fork_tcp_process():
>> init_child failed for process 27, pid 24762, "tcp receiver child=1"
>>
>> and then
>>
>>
>> 30(24765) : <core> [pass_fd.c:293]: ERROR: receive_fd: EOF on 45
>>  0(24735) ALERT: <core> [main.c:748]: child process 24762 exited
>> normally, status=255
>>  0(24735) INFO: <core> [main.c:766]: INFO: terminating due to SIGCHLD
>>
>> The problem happens on 4 different servers, I did try to compile more
>> than once, the servers are 32 Bit CentOS 5.6. The connection to the
>> database is monitored and there are no issues with connecting to the
>> DB "it works at times and times not for Kamailio so a user/pwd issue
>> is not likely to cause this, manual cnnect worked", config file errors
>> are not found.
>>
>> I did also check max no of connections on MySQL server which is set to
>> 500 on the server and only 100 cons are used. The group module uses
>> the same connection string as other modules  which is predefined  and
>> there are other modules that access the db before the group module and
>> those do not have a problem.
>>
>> Please advice.
>>
>> Regards
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users@...
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users@...
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>

--

-- 
Ali Jawad
Information Systems Manager
Splendor Telecom (www.splendor.net)
Beirut, Lebanon
Phone: +9611373725/ext 116
FAX: +9611375554

Sammy Govind | 2 Jan 2012 05:31
Picon

Re: [SR-Users] Intermittent start up issue

Hi,

Its all upto you then, that's an intermittent issue and information is not complete to trace the issue. Did you see the same Errors every time it fails !?

--
Regards
Sammy

On Sun, Jan 1, 2012 at 10:06 PM, Ali Jawad <ali.jawad-kFViwpaZTe3k1uMJSBkQmQ@public.gmane.org> wrote:
Hi
Thanks for your input, but as said this works at times yes and times
now so I am not sure it is a definite DB issue, the servers are in the
same LAN, and there are other modules that use the DB string that work
when launched before this one while this one does not work.
Regards

On Sun, Jan 1, 2012 at 4:13 PM, Sammy Govind <govoiper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi,
> forget the whole list of errors and just resolve the DB connectivity between
> the Kamailio server and DB server first .
>
>> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> connect to MySQL server on 'xxxxxxxxx' (4)
>
>
> try connecting to the remote DB server 'xxxxxxxxx' from linux shell i.e
>
> # mysql -u<user> -p<passwd> -h 'xxxxxxxxx'
>
> Regards,
> Sammy
>
>
> On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad <ali.jawad-kFViwpaZTe3k1uMJSBkQmQ@public.gmane.org> wrote:
>>
>> Hi All
>> I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is
>> that Kamailio at times fails to start up for no obvious reasons, I.e.
>> in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug
>> log "level 2 " shows the following :
>>
>> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> connect to MySQL server on 'xxxxxxxxx' (4)
>> 27(24762) ERROR: <core> [db.c:303]: could not add connection to the
>> pool27(24762) ERROR: group [group.c:211]: unable to connect to the
>> database
>> 27(24762) ERROR: <core> [sr_module.c:889]: init_mod_child(): Error
>> while initializing module group
>> (/usr/local/kamailio/lib/kamailio/modules_k/group.so)
>> 27(24762) ERROR: <core> [pt.c:481]: ERROR: fork_tcp_process():
>> init_child failed for process 27, pid 24762, "tcp receiver child=1"
>>
>> and then
>>
>>
>> 30(24765) : <core> [pass_fd.c:293]: ERROR: receive_fd: EOF on 45
>>  0(24735) ALERT: <core> [main.c:748]: child process 24762 exited
>> normally, status=255
>>  0(24735) INFO: <core> [main.c:766]: INFO: terminating due to SIGCHLD
>>
>> The problem happens on 4 different servers, I did try to compile more
>> than once, the servers are 32 Bit CentOS 5.6. The connection to the
>> database is monitored and there are no issues with connecting to the
>> DB "it works at times and times not for Kamailio so a user/pwd issue
>> is not likely to cause this, manual cnnect worked", config file errors
>> are not found.
>>
>> I did also check max no of connections on MySQL server which is set to
>> 500 on the server and only 100 cons are used. The group module uses
>> the same connection string as other modules  which is predefined  and
>> there are other modules that access the db before the group module and
>> those do not have a problem.
>>
>> Please advice.
>>
>> Regards
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users-cR8azDVoa3I@public.gmane.orgp-router.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users-cR8azDVoa3LnGTprPHx5SA@public.gmane.orguter.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>



--
Ali Jawad
Information Systems Manager
Splendor Telecom (www.splendor.net)
Beirut, Lebanon
Phone: +9611373725/ext 116
FAX: +9611375554

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users-cR8azDVoa3IcDhw6gZKtMeG/Ez6ZCGd0@public.gmane.orgorg
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

<div>
<p>Hi,</p>
<div>Its all upto you then,&nbsp;that's&nbsp;an intermittent issue and information is not complete to trace the issue. Did you see the same Errors&nbsp;every time&nbsp;it fails !?</div>
<div><br></div>
<div>--</div>
<div>Regards</div>
<div>
Sammy<br><br><div class="gmail_quote">On Sun, Jan 1, 2012 at 10:06 PM, Ali Jawad <span dir="ltr">&lt;<a href="mailto:ali.jawad@...">ali.jawad@...</a>&gt;</span> wrote:<br><blockquote class="gmail_quote">
Hi<br>
Thanks for your input, but as said this works at times yes and times<br>
now so I am not sure it is a definite DB issue, the servers are in the<br>
same LAN, and there are other modules that use the DB string that work<br>
when launched before this one while this one does not work.<br>
Regards<br><div class="HOEnZb"><div class="h5">
<br>
On Sun, Jan 1, 2012 at 4:13 PM, Sammy Govind &lt;<a href="mailto:govoiper <at> gmail.com">govoiper@...</a>&gt; wrote:<br>
&gt; Hi,<br>
&gt; forget the whole list of errors and just resolve the DB connectivity between<br>
&gt; the Kamailio server and DB server first .<br>
&gt;<br>
&gt;&gt; 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't<br>
&gt;&gt; connect to MySQL server on 'xxxxxxxxx' (4)<br>
&gt;<br>
&gt;<br>
&gt; try connecting to the remote DB server&nbsp;'xxxxxxxxx' from linux shell i.e<br>
&gt;<br>
&gt; # mysql -u&lt;user&gt; -p&lt;passwd&gt; -h&nbsp;'xxxxxxxxx'<br>
&gt;<br>
&gt; Regards,<br>
&gt; Sammy<br>
&gt;<br>
&gt;<br>
&gt; On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad &lt;<a href="mailto:ali.jawad@...">ali.jawad@...</a>&gt; wrote:<br>
&gt;&gt;<br>
&gt;&gt; Hi All<br>
&gt;&gt; I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is<br>
&gt;&gt; that Kamailio at times fails to&nbsp;start up&nbsp;for no obvious reasons, I.e.<br>
&gt;&gt; in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug<br>
&gt;&gt; log "level 2 " shows the following :<br>
&gt;&gt;<br>
&gt;&gt; 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't<br>
&gt;&gt; connect to MySQL server on 'xxxxxxxxx' (4)<br>
&gt;&gt; 27(24762) ERROR: &lt;core&gt; [db.c:303]: could not add connection to the<br>
&gt;&gt; pool27(24762) ERROR: group [group.c:211]: unable to connect to the<br>
&gt;&gt; database<br>
&gt;&gt; 27(24762) ERROR: &lt;core&gt; [sr_module.c:889]: init_mod_child(): Error<br>
&gt;&gt; while initializing module group<br>
&gt;&gt; (/usr/local/kamailio/lib/kamailio/modules_k/group.so)<br>
&gt;&gt; 27(24762) ERROR: &lt;core&gt; [pt.c:481]: ERROR: fork_tcp_process():<br>
&gt;&gt; init_child failed for process 27, pid 24762, "tcp receiver child=1"<br>
&gt;&gt;<br>
&gt;&gt; and then<br>
&gt;&gt;<br>
&gt;&gt;<br>
&gt;&gt; 30(24765) : &lt;core&gt; [pass_fd.c:293]: ERROR: receive_fd: EOF on 45<br>
&gt;&gt; &nbsp;0(24735) ALERT: &lt;core&gt; [main.c:748]: child process 24762 exited<br>
&gt;&gt; normally, status=255<br>
&gt;&gt; &nbsp;0(24735) INFO: &lt;core&gt; [main.c:766]: INFO: terminating due to SIGCHLD<br>
&gt;&gt;<br>
&gt;&gt; The problem happens on 4 different servers, I did try to compile more<br>
&gt;&gt; than once, the servers are 32 Bit CentOS 5.6. The connection to the<br>
&gt;&gt; database is monitored and there are no issues with connecting to the<br>
&gt;&gt; DB "it works at times and times not for Kamailio so a user/pwd issue<br>
&gt;&gt; is not likely to cause this, manual cnnect worked", config file errors<br>
&gt;&gt; are not found.<br>
&gt;&gt;<br>
&gt;&gt; I did also check max no of connections on MySQL server which is set to<br>
&gt;&gt; 500 on the server and only 100&nbsp;cons&nbsp;are used. The group module uses<br>
&gt;&gt; the same connection string as other modules &nbsp;which is predefined &nbsp;and<br>
&gt;&gt; there are other modules that access the db before the group module and<br>
&gt;&gt; those do not have a problem.<br>
&gt;&gt;<br>
&gt;&gt; Please advice.<br>
&gt;&gt;<br>
&gt;&gt; Regards<br>
&gt;&gt;<br>
&gt;&gt; _______________________________________________<br>
&gt;&gt; SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
&gt;&gt; <a href="mailto:sr-users@...">sr-users@...p-router.org</a><br>
&gt;&gt; <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br>
&gt; <a href="mailto:sr-users@...">sr-users@...uter.org</a><br>
&gt; <a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
&gt;<br><br><br><br>
</div></div>
<span class="HOEnZb">--<br>
Ali Jawad<br>
Information Systems Manager<br>
Splendor Telecom (<a href="http://www.splendor.net" target="_blank">www.splendor.net</a>)<br>
Beirut, Lebanon<br>
Phone: <a href="tel:%2B9611373725" value="+9611373725">+9611373725</a>/ext 116<br>
FAX: <a href="tel:%2B9611375554" value="+9611375554">+9611375554</a><br></span><div class="HOEnZb"><div class="h5">
<br>
_______________________________________________<br>
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list<br><a href="mailto:sr-users@...">sr-users@...org</a><br><a href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div></div>
</blockquote>
</div>
<br>
</div>
</div>
Daniel-Constantin Mierla | 2 Jan 2012 12:00
Picon

Re: [SR-Users] Problems with video behind NAT

Hello,

is Asterisk supposed to forward the video stream as well? When you mean Asrerisk has only local address, means its address is not routable from the sip clients, right? If yes, have you set rtpproxy in bridged mode?

A ngrep trace of the sip signaling for a call which does not work would be useful to provide more details about what could be wrong there.

Cheers,
Daniel

On 12/29/11 11:38 PM, Stoyan Mihaylov wrote:
My whole configuration is:
[Sip clients] < = > Kamailio 3.2 <=> Asterisk servers (behind Kamailio)
Asterisk servers have only local IP addresses, and I use t_relay instead of forward.
Kamailio runs on same server as rtpproxy.

Now I played lot of combinations and I have next results:
1. Clients are in same net with Kamailio server (and Asterisk server). Client call Kamailio, Kamailio t_relay to Asterisk, Asterisk dial back to Kamailio, and Kamailio dial Client. rtpproxy is working. Video and audio are fine...
2. Same as above, but clients are behind NAT. Sound is perfect, no video.
3. Same as in point 1, but no rtpproxy, and no Asterisk servers. Sound and video are perfect. With rtpproxy - no voice, no video.

I would like to find solution for point 2. Sound and video are on different rports (seen in wireshark). As I understand, my error is either in wrong forwarding of ACK (I do t_relay to Asterisk in case from and to addresses are same), or may be I have to find correct FLAGS for rtpproxy_manage(), or even replace it and place with rtpproxy_offer (answer etc).

Bellow is my kamailio.cfg:
####### Defined Values #########
#!define WITH_MYSQL
#!define WITH_AUTH
#!define WITH_USRLOCDB

#!define WITH_IPAUTH
#!define WITH_NAT
#!define WITH_PSTN

# *** Value defines - IDs used later in config
#!define MULTIDOMAIN 0

#!define FLT_ACC 1
#!define FLT_ACCMISSED 2
#!define FLT_ACCFAILED 3
#!define FLT_NATS 5

#!define FLB_NATB 6
#!define FLB_NATSIPPING 7

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

debug=3
log_stderror=no

memdbg=5
memlog=5

log_facility=LOG_LOCAL0

fork=yes
children=4

port=5060

tcp_connection_lifetime=3605
#!ifdef WITH_PSTN
pstn.gw_ip = "192.168.2.251" desc "PSTN GW Address"
#!endif


# set paths to location of modules (to sources or installation folders)
#!ifdef WITH_SRCPATH
mpath="modules_k:modules"
#!else
mpath="//lib64/kamailio/modules_k/://lib64/kamailio/modules/"
#!endif

#!ifdef WITH_MYSQL
loadmodule "db_mysql.so"
#!endif

loadmodule "mi_fifo.so"
loadmodule "kex.so"
loadmodule "tm.so"
loadmodule "tmx.so"
loadmodule "sl.so"
loadmodule "rr.so"
loadmodule "pv.so"
loadmodule "maxfwd.so"
loadmodule "usrloc.so"
loadmodule "registrar.so"
loadmodule "textops.so"
loadmodule "siputils.so"
loadmodule "xlog.so"
loadmodule "sanity.so"
loadmodule "ctl.so"
loadmodule "cfg_rpc.so"
loadmodule "mi_rpc.so"
loadmodule "acc.so"

#!ifdef WITH_AUTH
loadmodule "auth.so"
loadmodule "auth_db.so"
#!ifdef WITH_IPAUTH
loadmodule "permissions.so"
#!endif
#!endif

#!ifdef WITH_ALIASDB
loadmodule "alias_db.so"
#!endif

#!ifdef WITH_SPEEDDIAL
loadmodule "speeddial.so"
#!endif

#!ifdef WITH_MULTIDOMAIN
loadmodule "domain.so"
#!endif

#!ifdef WITH_PRESENCE
loadmodule "presence.so"
loadmodule "presence_xml.so"
#!endif

#!ifdef WITH_NAT
loadmodule "nathelper.so"
loadmodule "rtpproxy.so"
#!endif

#!ifdef WITH_TLS
loadmodule "tls.so"
#!endif

loadmodule "htable.so"
#!ifdef WITH_ANTIFLOOD
loadmodule "pike.so"
#!endif

#!ifdef WITH_XMLRPC
loadmodule "xmlrpc.so"
#!endif

#!ifdef WITH_DEBUG
loadmodule "debugger.so"
#!endif

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


loadmodule "dispatcher.so"
modparam("dispatcher", "db_url", DBURL)
# ----- mi_fifo params -----
modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")


# ----- tm params -----
# auto-discard branches from previous serial forking leg
modparam("tm", "failure_reply_mode", 3)
# default retransmission timeout: 30sec
modparam("tm", "fr_timer", 30000)
# default invite retransmission timeout after 1xx: 120sec
modparam("tm", "fr_inv_timer", 120000)


# ----- 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)
# max value for expires of registrations
modparam("registrar", "max_expires", 3600)


# ----- acc params -----
/* what special events should be accounted ? */
modparam("acc", "early_media", 0)
modparam("acc", "report_ack", 0)
modparam("acc", "report_cancels", 0)
modparam("acc", "detect_direction", 0)
/* account triggers (flags) */
modparam("acc", "log_flag", FLT_ACC)
modparam("acc", "log_missed_flag", FLT_ACCMISSED)
modparam("acc", "log_extra", 
"src_user=$fU;src_domain=$fd;src_ip=$si;"
"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)
/* enhanced DB accounting */
#!ifdef WITH_ACCDB
modparam("acc", "db_flag", FLT_ACC)
modparam("acc", "db_missed_flag", FLT_ACCMISSED)
modparam("acc", "db_url", DBURL)
modparam("acc", "db_extra",
"src_user=$fU;src_domain=$fd;src_ip=$si;"
"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")
#!endif
#!ifdef WITH_USRLOCDB
modparam("usrloc", "db_url", DBURL)
modparam("usrloc", "db_mode", 2)
modparam("usrloc", "use_domain", MULTIDOMAIN)
#!endif
#!ifdef WITH_AUTH
modparam("auth_db", "db_url", DBURL)
modparam("auth_db", "calculate_ha1", yes)
modparam("auth_db", "password_column", "password")
modparam("auth_db", "load_credentials", "")
modparam("auth_db", "use_domain", MULTIDOMAIN)
#!ifdef WITH_IPAUTH
modparam("permissions", "db_url", DBURL)
modparam("permissions", "db_mode", 1)
#!endif
#!endif
#!ifdef WITH_ALIASDB
modparam("alias_db", "db_url", DBURL)
modparam("alias_db", "use_domain", MULTIDOMAIN)
#!endif

# ----- speedial params -----
#!ifdef WITH_SPEEDDIAL
modparam("speeddial", "db_url", DBURL)
modparam("speeddial", "use_domain", MULTIDOMAIN)
#!endif


#!ifdef WITH_NAT
# ----- rtpproxy params -----
modparam("rtpproxy", "rtpproxy_sock", "udp:127.0.0.1:7722")

# ----- nathelper params -----
modparam("nathelper", "natping_interval", 30)
modparam("nathelper", "ping_nated_only", 1)
modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)
modparam("nathelper", "sipping_from", "sip:pinger-j+PTJLu+TTpg9hUCZPvPmw@public.gmane.org")

# params needed for NAT traversal in other modules
modparam("nathelper|registrar", "received_avp", "$avp(RECEIVED)")
modparam("usrloc", "nat_bflag", FLB_NATB)
#!endif


#!ifdef WITH_TLS
# ----- tls params -----
modparam("tls", "config", "//etc/kamailio/tls.cfg")
#!endif

modparam("htable", "htable", "forw=>size=8;autoexpire=7200;")


#!ifdef WITH_DEBUG
# ----- debugger params -----
modparam("debugger", "cfgtrace", 1)
#!endif

request_route {
xlog("L_ALERT","Pakage $rm from $fu (IP:$si:$sp)\n");
# per request initial checks
route(REQINIT);

# NAT detection
route(NATDETECT);
route(ACKBYE);

# handle requests within SIP dialogs
route(WITHINDLG);
if (is_method("CANCEL"))
{
if (t_check_trans())
t_relay();
exit;
}
t_check_trans();
route(AUTH);
# record routing for dialog forming requests (in case they are routed)
# - remove preloaded route headers
remove_hf("Route");
if (is_method("INVITE|SUBSCRIBE"))
record_route();
# account only INVITEs
if (is_method("INVITE"))
{
setflag(FLT_ACC); # do accounting
}
route(SIPOUT);
route(PRESENCE);
route(REGISTRAR);
if ($rU==$null)
{
sl_send_reply("484","Address Incomplete");
exit;
}
route(PSTN);
route(LOCATION);
route(RELAY);
}

route[RELAY] {
if (is_method("INVITE|SUBSCRIBE")) {
t_on_branch("MANAGE_BRANCH");
t_on_reply("MANAGE_REPLY");
}
if (is_method("INVITE")) {
t_on_failure("MANAGE_FAILURE");
}
if (!t_relay()) {
sl_reply_error();
}
exit;
}

route[REQINIT] {
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}

if(!sanity_check("1511", "7"))
{
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
}

# Handle requests within SIP dialogs
route[WITHINDLG] {
if (has_totag()) {
if (loose_route()) {
if (is_method("BYE")) {
setflag(FLT_ACC); # do accounting ...
setflag(FLT_ACCFAILED); # ... even if the transaction fails
}
if ( is_method("ACK") ) {
# ACK is forwarded statelessy
route(NATMANAGE);
}
route(RELAY);
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
t_relay();
exit;
} else {
# ACK without matching transaction ... ignore and discard
exit;
}
}
sl_send_reply("404","Not here");
}
exit;
}
}

# Handle SIP registrations
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();
exit;
}
}

# USER location service
route[LOCATION] {
$avp(oexten) = $rU;
if (!lookup("location")) {
$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);
}
}

# Presence server route
route[PRESENCE] {
if(!is_method("PUBLISH|SUBSCRIBE"))
return;
# if presence enabled, this part will not be executed
if (is_method("PUBLISH") || $rU==$null)
{
sl_send_reply("404", "Not here");
exit;
}
return;
}

# Authentication route
route[AUTH] {
#!ifdef WITH_AUTH
if (is_method("REGISTER"))
{
# authenticate the REGISTER requests (uncomment to enable auth)
if (!www_authorize("$td", "subscriber"))
{
www_challenge("$td", "0");
exit;
}

if ($au!=$tU)
{
sl_send_reply("403","Forbidden auth ID");
exit;
}
} else {

#!ifdef WITH_IPAUTH
if(allow_source_address())
{
# source IP allowed
return;
}
#!endif

# authenticate if from local subscriber
if (from_uri==myself)
{
if (!proxy_authorize("$fd", "subscriber")) {
proxy_challenge("$fd", "0");
exit;
}
if (is_method("PUBLISH"))
{
if ($au!=$fU || $au!=$tU) {
sl_send_reply("403","Forbidden auth ID");
exit;
}
if ($au!=$rU) {
sl_send_reply("403","Forbidden R-URI");
exit;
}
} else {
if ($au!=$fU) {
sl_send_reply("403","Forbidden auth ID");
exit;
}
}

consume_credentials();
# caller authenticated
} else {
# a local destination, otherwise deny, not an open relay here
if (!uri==myself)
{
sl_send_reply("403","Not relaying");
exit;
}
}
}
#!endif
return;
}

# Caller NAT detection route
route[NATDETECT] {
#!ifdef WITH_NAT
force_rport();
if (nat_uac_test("19")) {
if (is_method("REGISTER")) {
fix_nated_register();
} else {
fix_nated_contact();
}
setflag(FLT_NATS);
}
#!endif
return;
}

# RTPProxy control
route[NATMANAGE] {
#!ifdef WITH_NAT
if (is_request()) {
if(has_totag()) {
if(check_route_param("nat=yes")) {
setbflag(FLB_NATB);
}
}
}
if (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))
return;
rtpproxy_manage();
if (is_request()) {
if (!has_totag()) {
add_rr_param(";nat=yes");
}
}
if (is_reply()) {
if(isbflagset(FLB_NATB)) {
fix_nated_contact();
}
}
#!endif
return;
}

# Routing to foreign domains
route[SIPOUT] {
if (!uri==myself)
{
append_hf("P-hint: outbound\r\n");
route(RELAY);
}
}

route[ACKBYE] {
#!ifdef WITH_PSTN
if (is_method("BYE|ACK"))
{
xlog("L_ALERT","AB $rm $sht(forw=>$ft) $td");
if(($sht(forw=>$ft))=~"MessageCPIM"){
# Direct messages between clients
xlog("L_ALERT","AB $rm CPIM $td");
return;
}
if(src_ip==$td){
#I have to rewrite du - messages loop in Kamailio
xlog("L_ALERT","ACK,Bye Method equalIP");
$du=$sht(forw=>$ft);
xlog("L_ALERT","ACK,Bye $ft $du");
route(RELAY);
exit;
}
xlog("L_ALERT","ACK,Bye Not me");
}
#!endif
return;
}
route[PSTNINVITE] {
if(is_method("INVITE")){
if($rb=~"message/CPIM"){
# Direct messages between clients
$sht(forw=>$ft)="MessageCPIM";
route(LOCATION);
route(RELAY);
}
#This way I can select from multiple Asterisk servers. I will t_relay instead of forward, because Asterisk servers are with local IP.
ds_select_dst("1","4");
$sht(forw=>$ft)=$du;
sl_send_reply("100","Trying");
route(RELAY);
exit();
}
}
route[PSTN] {
#I am using this routine to forward to Asterisks (instead of additional one for balancing)
#!ifdef WITH_PSTN
# check if PSTN GW IP is defined
if (strempty($sel(cfg_get.pstn.gw_ip))) {
xlog("SCRIPT: PSTN rotuing enabled but pstn.gw_ip not defined\n");
return;
}
if(allow_source_address())
return;
if(from_uri!=myself) {
sl_send_reply("403", "Not Allowed");
exit;
}
if(is_method("MESSAGE"))
return;
route(PSTNINVITE);
route(RELAY);
exit;
#!endif
return;
}


# route to voicemail server
route[TOVOICEMAIL] {
return;
}

# manage outgoing branches
branch_route[MANAGE_BRANCH] {
xdbg("new branch [$T_branch_idx] to $ru\n");
route(NATMANAGE);
}

# manage incoming replies
onreply_route[MANAGE_REPLY] {
xdbg("incoming reply\n");
if(status=~"[12][0-9][0-9]")
route(NATMANAGE);
}

# manage failure routing cases
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_VOICEMAIL
# serial forking
# - route to voicemail on busy or no answer (timeout)
if (t_check_status("486|408")) {
route(TOVOICEMAIL);
exit;
}
#!endif
}


_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+b@public.gmane.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- Daniel-Constantin Mierla -- http://www.asipto.com http://linkedin.com/in/miconda -- http://twitter.com/miconda
<div>
    Hello,<br><br>
    is Asterisk supposed to forward the video stream as well? When you
    mean Asrerisk has only local address, means its address is not
    routable from the sip clients, right? If yes, have you set rtpproxy
    in bridged mode?<br><br>
    A ngrep trace of the sip signaling for a call which does not work
    would be useful to provide more details about what could be wrong
    there.<br><br>
    Cheers,<br>
    Daniel<br><br>
    On 12/29/11 11:38 PM, Stoyan Mihaylov wrote:
    <blockquote cite="mid:CAPScudYHR-FQGgBSp5mke1TLpZtH1DAhhsGf7QYM3iccQ5ipsA@..." type="cite">
      <div>My whole configuration is:</div>
      <div>[Sip clients] &lt; = &gt; Kamailio 3.2 &lt;=&gt; Asterisk
        servers (behind Kamailio)</div>
      <div>Asterisk servers have only local IP addresses, and I use
        t_relay instead of forward.</div>
      <div>Kamailio runs on same server as rtpproxy.</div>
      <div><br></div>
      <div>Now I played lot of combinations and I have next results:</div>
      <div>1. Clients are in same net with Kamailio server (and Asterisk
        server). Client call Kamailio, Kamailio t_relay to Asterisk,
        Asterisk dial back to Kamailio, and Kamailio dial Client.
        rtpproxy is working. Video and audio are fine...</div>
      <div>2. Same as above, but clients are behind NAT. Sound is
        perfect, no video.</div>
      <div>3. Same as in point 1, but no rtpproxy, and no Asterisk
        servers. Sound and video are perfect. With rtpproxy - no voice,
        no video.</div>
      <div><br></div>
      <div>I would like to find solution for point 2. Sound and video
        are on different rports (seen in wireshark). As I understand, my
        error is either in wrong forwarding of ACK (I do t_relay to
        Asterisk in case from and to addresses are same), or may be I
        have to find correct FLAGS for rtpproxy_manage(), or even
        replace it and place with rtpproxy_offer (answer etc).</div>
      <div><br></div>
      <div>Bellow is my kamailio.cfg:</div>
      <div>####### Defined Values #########</div>
      <div>#!define WITH_MYSQL</div>
      <div>#!define WITH_AUTH</div>
      <div>#!define WITH_USRLOCDB</div>
      <div><br></div>
      <div>#!define WITH_IPAUTH</div>
      <div>#!define WITH_NAT</div>
      <div>#!define WITH_PSTN</div>
      <div><br></div>
      <div># *** Value defines - IDs used later in config</div>
      <div>#!define DBURL "mysql://<a moz-do-not-send="true" href="http://user:pass-Q0ErXNX1RuY52RfiMZAvOA <at> public.gmane.org/openser">user:pass@.../openser</a>"</div>
      <div>#!define MULTIDOMAIN 0</div>
      <div><br></div>
      <div>#!define FLT_ACC 1</div>
      <div>#!define FLT_ACCMISSED 2</div>
      <div>#!define FLT_ACCFAILED 3</div>
      <div>#!define FLT_NATS 5</div>
      <div><br></div>
      <div>#!define FLB_NATB 6</div>
      <div>#!define FLB_NATSIPPING 7</div>
      <div><br></div>
      <div>####### Global Parameters #########</div>
      <div><br></div>
      <div>debug=3</div>
      <div>log_stderror=no</div>
      <div><br></div>
      <div>memdbg=5</div>
      <div>memlog=5</div>
      <div><br></div>
      <div>log_facility=LOG_LOCAL0</div>
      <div><br></div>
      <div>fork=yes</div>
      <div>children=4</div>
      <div><br></div>
      <div>port=5060</div>
      <div><br></div>
      <div>tcp_connection_lifetime=3605</div>
      <div>#!ifdef WITH_PSTN</div>
      <div>pstn.gw_ip = "192.168.2.251" desc "PSTN GW Address"</div>
      <div>#!endif</div>
      <div><br></div>
      <div><br></div>
      <div># set paths to location of modules (to sources or
        installation folders)</div>
      <div>#!ifdef WITH_SRCPATH</div>
      <div>mpath="modules_k:modules"</div>
      <div>#!else</div>
      <div>mpath="//lib64/kamailio/modules_k/://lib64/kamailio/modules/"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_MYSQL</div>
      <div>loadmodule "db_mysql.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>loadmodule "mi_fifo.so"</div>
      <div>loadmodule "kex.so"</div>
      <div>loadmodule "tm.so"</div>
      <div>loadmodule "tmx.so"</div>
      <div>loadmodule "sl.so"</div>
      <div>loadmodule "rr.so"</div>
      <div>loadmodule "pv.so"</div>
      <div>loadmodule "maxfwd.so"</div>
      <div>loadmodule "usrloc.so"</div>
      <div>loadmodule "registrar.so"</div>
      <div>loadmodule "textops.so"</div>
      <div>loadmodule "siputils.so"</div>
      <div>loadmodule "xlog.so"</div>
      <div>loadmodule "sanity.so"</div>
      <div>loadmodule "ctl.so"</div>
      <div>loadmodule "cfg_rpc.so"</div>
      <div>loadmodule "mi_rpc.so"</div>
      <div>loadmodule "acc.so"</div>
      <div><br></div>
      <div>#!ifdef WITH_AUTH</div>
      <div>loadmodule "auth.so"</div>
      <div>loadmodule "auth_db.so"</div>
      <div>#!ifdef WITH_IPAUTH</div>
      <div>loadmodule "permissions.so"</div>
      <div>#!endif</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_ALIASDB</div>
      <div>loadmodule "alias_db.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_SPEEDDIAL</div>
      <div>loadmodule "speeddial.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_MULTIDOMAIN</div>
      <div>loadmodule "domain.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_PRESENCE</div>
      <div>loadmodule "presence.so"</div>
      <div>loadmodule "presence_xml.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_NAT</div>
      <div>loadmodule "nathelper.so"</div>
      <div>loadmodule "rtpproxy.so"</div>
      <div>#!endif</div>
      <div>
        <br>
</div>
      <div>#!ifdef WITH_TLS</div>
      <div>loadmodule "tls.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>loadmodule "htable.so"</div>
      <div>#!ifdef WITH_ANTIFLOOD</div>
      <div>loadmodule "pike.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_XMLRPC</div>
      <div>loadmodule "xmlrpc.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_DEBUG</div>
      <div>loadmodule "debugger.so"</div>
      <div>#!endif</div>
      <div><br></div>
      <div># ----------------- setting module-specific parameters
        ---------------</div>
      <div><br></div>
      <div><br></div>
      <div>loadmodule "dispatcher.so"</div>
      <div>modparam("dispatcher", "db_url", DBURL)</div>
      <div># ----- mi_fifo params -----</div>
      <div>modparam("mi_fifo", "fifo_name", "/tmp/kamailio_fifo")</div>
      <div><br></div>
      <div><br></div>
      <div># ----- tm params -----</div>
      <div># auto-discard branches from previous serial forking leg</div>
      <div>modparam("tm", "failure_reply_mode", 3)</div>
      <div># default retransmission timeout: 30sec</div>
      <div>modparam("tm", "fr_timer", 30000)</div>
      <div># default invite retransmission timeout after 1xx: 120sec</div>
      <div>modparam("tm", "fr_inv_timer", 120000)</div>
      <div><br></div>
      <div><br></div>
      <div># ----- rr params -----</div>
      <div># add value to ;lr param to cope with most of the UAs</div>
      <div>modparam("rr", "enable_full_lr", 1)</div>
      <div># do not append from tag to the RR (no need for this script)</div>
      <div>modparam("rr", "append_fromtag", 0)</div>
      <div><br></div>
      <div><br></div>
      <div># ----- registrar params -----</div>
      <div>modparam("registrar", "method_filtering", 1)</div>
      <div>/* uncomment the next line to disable parallel forking via
        location */</div>
      <div># modparam("registrar", "append_branches", 0)</div>
      <div>/* uncomment the next line not to allow more than 10 contacts
        per AOR */</div>
      <div>#modparam("registrar", "max_contacts", 10)</div>
      <div># max value for expires of registrations</div>
      <div>modparam("registrar", "max_expires", 3600)</div>
      <div><br></div>
      <div><br></div>
      <div># ----- acc params -----</div>
      <div>/* what special events should be accounted ? */</div>
      <div>modparam("acc", "early_media", 0)</div>
      <div>modparam("acc", "report_ack", 0)</div>
      <div>modparam("acc", "report_cancels", 0)</div>
      <div>modparam("acc", "detect_direction", 0)</div>
      <div>/* account triggers (flags) */</div>
      <div>modparam("acc", "log_flag", FLT_ACC)</div>
      <div>modparam("acc", "log_missed_flag", FLT_ACCMISSED)</div>
      <div>modparam("acc", "log_extra",&nbsp;</div>
      <div>
<span class="Apple-tab-span"> </span>"src_user=$fU;src_domain=$fd;src_ip=$si;"</div>
      <div>
<span class="Apple-tab-span"> </span>"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")</div>
      <div>modparam("acc", "failed_transaction_flag", FLT_ACCFAILED)</div>
      <div>/* enhanced DB accounting */</div>
      <div>#!ifdef WITH_ACCDB</div>
      <div>modparam("acc", "db_flag", FLT_ACC)</div>
      <div>modparam("acc", "db_missed_flag", FLT_ACCMISSED)</div>
      <div>modparam("acc", "db_url", DBURL)</div>
      <div>modparam("acc", "db_extra",</div>
      <div>
<span class="Apple-tab-span"> </span>"src_user=$fU;src_domain=$fd;src_ip=$si;"</div>
      <div>
<span class="Apple-tab-span"> </span>"dst_ouser=$tU;dst_user=$rU;dst_domain=$rd")</div>
      <div>#!endif</div>
      <div>#!ifdef WITH_USRLOCDB</div>
      <div>modparam("usrloc", "db_url", DBURL)</div>
      <div>modparam("usrloc", "db_mode", 2)</div>
      <div>modparam("usrloc", "use_domain", MULTIDOMAIN)</div>
      <div>#!endif</div>
      <div>#!ifdef WITH_AUTH</div>
      <div>modparam("auth_db", "db_url", DBURL)</div>
      <div>modparam("auth_db", "calculate_ha1", yes)</div>
      <div>modparam("auth_db", "password_column", "password")</div>
      <div>modparam("auth_db", "load_credentials", "")</div>
      <div>modparam("auth_db", "use_domain", MULTIDOMAIN)</div>
      <div>#!ifdef WITH_IPAUTH</div>
      <div>modparam("permissions", "db_url", DBURL)</div>
      <div>modparam("permissions", "db_mode", 1)</div>
      <div>#!endif</div>
      <div>#!endif</div>
      <div>#!ifdef WITH_ALIASDB</div>
      <div>modparam("alias_db", "db_url", DBURL)</div>
      <div>modparam("alias_db", "use_domain", MULTIDOMAIN)</div>
      <div>#!endif</div>
      <div><br></div>
      <div># ----- speedial params -----</div>
      <div>#!ifdef WITH_SPEEDDIAL</div>
      <div>modparam("speeddial", "db_url", DBURL)</div>
      <div>modparam("speeddial", "use_domain", MULTIDOMAIN)</div>
      <div>#!endif</div>
      <div><br></div>
      <div><br></div>
      <div>#!ifdef WITH_NAT</div>
      <div># ----- rtpproxy params -----</div>
      <div>modparam("rtpproxy", "rtpproxy_sock", "udp:<a moz-do-not-send="true" href="http://127.0.0.1:7722">127.0.0.1:7722</a>")</div>
      <div><br></div>
      <div># ----- nathelper params -----</div>
      <div>modparam("nathelper", "natping_interval", 30)</div>
      <div>modparam("nathelper", "ping_nated_only", 1)</div>
      <div>modparam("nathelper", "sipping_bflag", FLB_NATSIPPING)</div>
      <div>modparam("nathelper", "sipping_from", "<a moz-do-not-send="true" href="mailto:sip%3Apinger@...">sip:pinger@...</a>")</div>
      <div><br></div>
      <div># params needed for NAT traversal in other modules</div>
      <div>modparam("nathelper|registrar", "received_avp",
        "$avp(RECEIVED)")</div>
      <div>modparam("usrloc", "nat_bflag", FLB_NATB)</div>
      <div>#!endif</div>
      <div><br></div>
      <div><br></div>
      <div>#!ifdef WITH_TLS</div>
      <div># ----- tls params -----</div>
      <div>modparam("tls", "config", "//etc/kamailio/tls.cfg")</div>
      <div>#!endif</div>
      <div><br></div>
      <div>modparam("htable", "htable",
        "forw=&gt;size=8;autoexpire=7200;")</div>
      <div><br></div>
      <div><br></div>
      <div>#!ifdef WITH_DEBUG</div>
      <div># ----- debugger params -----</div>
      <div>modparam("debugger", "cfgtrace", 1)</div>
      <div>#!endif</div>
      <div><br></div>
      <div>request_route {</div>
      <div>xlog("L_ALERT","Pakage $rm from $fu (IP:$si:$sp)\n");</div>
      <div>
<span class="Apple-tab-span"> </span>#
        per request initial checks</div>
      <div>
<span class="Apple-tab-span"> </span>route(REQINIT);</div>
      <div><br></div>
      <div>
<span class="Apple-tab-span"> </span>#
        NAT detection</div>
      <div>
<span class="Apple-tab-span"> </span>route(NATDETECT);</div>
      <div>
<span class="Apple-tab-span"> </span>route(ACKBYE);</div>
      <div><br></div>
      <div>
<span class="Apple-tab-span"> </span>#
        handle requests within SIP dialogs</div>
      <div>
<span class="Apple-tab-span"> </span>route(WITHINDLG);</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("CANCEL"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (t_check_trans())</div>
      <div>
<span class="Apple-tab-span"> </span>t_relay();</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>t_check_trans();</div>
      <div>
<span class="Apple-tab-span"> </span>route(AUTH);</div>
      <div>
<span class="Apple-tab-span"> </span>#
        record routing for dialog forming requests (in case they are
        routed)</div>
      <div>
<span class="Apple-tab-span"> </span>#
        - remove preloaded route headers</div>
      <div>
<span class="Apple-tab-span"> </span>remove_hf("Route");</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("INVITE|SUBSCRIBE"))</div>
      <div>
<span class="Apple-tab-span"> </span>record_route();</div>
      <div>
<span class="Apple-tab-span"> </span>#
        account only INVITEs</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("INVITE"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>setflag(FLT_ACC);
        # do accounting</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>route(SIPOUT);</div>
      <div>
<span class="Apple-tab-span"> </span>route(PRESENCE);</div>
      <div>
<span class="Apple-tab-span"> </span>route(REGISTRAR);</div>
      <div>
<span class="Apple-tab-span"> </span>if
        ($rU==$null)</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("484","Address
        Incomplete");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>route(PSTN);</div>
      <div>
<span class="Apple-tab-span"> </span>route(LOCATION);</div>
      <div>
<span class="Apple-tab-span"> </span>route(RELAY);</div>
      <div>}</div>
      <div><br></div>
      <div>route[RELAY] {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("INVITE|SUBSCRIBE")) {</div>
      <div>
<span class="Apple-tab-span"> </span>t_on_branch("MANAGE_BRANCH");</div>
      <div>
<span class="Apple-tab-span"> </span>t_on_reply("MANAGE_REPLY");</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("INVITE")) {</div>
      <div>
<span class="Apple-tab-span"> </span>t_on_failure("MANAGE_FAILURE");</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!t_relay()) {</div>
      <div>
<span class="Apple-tab-span"> </span>sl_reply_error();</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>}</div>
      <div><br></div>
      <div>route[REQINIT] {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!mf_process_maxfwd_header("10")) {</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("483","Too
        Many Hops");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div><br></div>
      <div>
<span class="Apple-tab-span"> </span>if(!sanity_check("1511",
        "7"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>xlog("Malformed
        SIP message from $si:$sp\n");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>}</div>
      <div><br></div>
      <div># Handle requests within SIP dialogs</div>
      <div>route[WITHINDLG] {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (has_totag()) {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (loose_route()) {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("BYE")) {</div>
      <div>
<span class="Apple-tab-span"> </span>setflag(FLT_ACC);
        # do accounting ...</div>
      <div>
<span class="Apple-tab-span"> </span>setflag(FLT_ACCFAILED);
        # ... even if the transaction fails</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        ( is_method("ACK") ) {</div>
      <div>
<span class="Apple-tab-span"> </span>#
        ACK is forwarded statelessy</div>
      <div>
<span class="Apple-tab-span"> </span>route(NATMANAGE);</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>route(RELAY);</div>
      <div>
<span class="Apple-tab-span"> </span>}
        else {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("SUBSCRIBE") &amp;&amp; uri == myself) {</div>
      <div>
<span class="Apple-tab-span"> </span>#
        in-dialog subscribe requests</div>
      <div>
<span class="Apple-tab-span"> </span>route(PRESENCE);</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        ( is_method("ACK") ) {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        ( t_check_trans() ) {</div>
      <div>
<span class="Apple-tab-span"> </span>t_relay();</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}
        else {</div>
      <div>
<span class="Apple-tab-span"> </span>#
        ACK without matching transaction ... ignore and discard</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("404","Not
        here");</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>}</div>
      <div><br></div>
      <div># Handle SIP registrations</div>
      <div>route[REGISTRAR] {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("REGISTER"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>if(isflagset(FLT_NATS))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>setbflag(FLB_NATB);</div>
      <div>
<span class="Apple-tab-span"> </span>#
        uncomment next line to do SIP NAT pinging&nbsp;</div>
      <div>
<span class="Apple-tab-span"> </span>##
        setbflag(FLB_NATSIPPING);</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!save("location"))</div>
      <div>
<span class="Apple-tab-span"> </span>sl_reply_error();</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>}</div>
      <div><br></div>
      <div># USER location service</div>
      <div>route[LOCATION] {</div>
      <div>
<span class="Apple-tab-span"> </span>$avp(oexten)
        = $rU;</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!lookup("location")) {</div>
      <div>
<span class="Apple-tab-span"> </span>$var(rc)
        = $rc;</div>
      <div>
<span class="Apple-tab-span"> </span>route(TOVOICEMAIL);</div>
      <div>
<span class="Apple-tab-span"> </span>t_newtran();</div>
      <div>
<span class="Apple-tab-span"> </span>switch
        ($var(rc)) {</div>
      <div>
<span class="Apple-tab-span"> </span>case
        -1:</div>
      <div>
<span class="Apple-tab-span"> </span>case
        -3:</div>
      <div>
<span class="Apple-tab-span"> </span>send_reply("404",
        "Not Found");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>case
        -2:</div>
      <div>
<span class="Apple-tab-span"> </span>send_reply("405",
        "Method Not Allowed");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>#
        when routing via usrloc, log the missed calls also</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("INVITE"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>setflag(FLT_ACCMISSED);</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>}</div>
      <div><br></div>
      <div># Presence server route</div>
      <div>route[PRESENCE] {</div>
      <div>
<span class="Apple-tab-span"> </span>if(!is_method("PUBLISH|SUBSCRIBE"))</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div><span class="Apple-tab-span"> </span></div>
      <div>
<span class="Apple-tab-span"> </span>#
        if presence enabled, this part will not be executed</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("PUBLISH") || $rU==$null)</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("404",
        "Not here");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>}</div>
      <div><br></div>
      <div># Authentication route</div>
      <div>route[AUTH] {</div>
      <div>#!ifdef WITH_AUTH</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("REGISTER"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>#
        authenticate the REGISTER requests (uncomment to enable auth)</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!www_authorize("$td", "subscriber"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>www_challenge("$td",
        "0");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div><br></div>
      <div>
<span class="Apple-tab-span"> </span>if
        ($au!=$tU)</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("403","Forbidden
        auth ID");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}
        else {</div>
      <div><br></div>
      <div>#!ifdef WITH_IPAUTH</div>
      <div>
<span class="Apple-tab-span"> </span>if(allow_source_address())</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>#
        source IP allowed</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#!endif</div>
      <div><br></div>
      <div>
<span class="Apple-tab-span"> </span>#
        authenticate if from local subscriber</div>
      <div>
        <span class="Apple-tab-span"> </span>if
        (from_uri==myself)</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!proxy_authorize("$fd", "subscriber")) {</div>
      <div>
<span class="Apple-tab-span"> </span>proxy_challenge("$fd",
        "0");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("PUBLISH"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>if
        ($au!=$fU || $au!=$tU) {</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("403","Forbidden
        auth ID");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
        <span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        ($au!=$rU) {</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("403","Forbidden
        R-URI");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}
        else {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        ($au!=$fU) {</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("403","Forbidden
        auth ID");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div><br></div>
      <div>
<span class="Apple-tab-span"> </span>consume_credentials();</div>
      <div>
<span class="Apple-tab-span"> </span>#
        caller authenticated</div>
      <div>
<span class="Apple-tab-span"> </span>}
        else {</div>
      <div>
<span class="Apple-tab-span"> </span>#
        a local destination, otherwise deny, not an open relay here</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!uri==myself)</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("403","Not
        relaying");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#!endif</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>}</div>
      <div><br></div>
      <div># Caller NAT detection route</div>
      <div>route[NATDETECT] {</div>
      <div>#!ifdef WITH_NAT</div>
      <div>
        <span class="Apple-tab-span"> </span>force_rport();</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (nat_uac_test("19")) {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("REGISTER")) {</div>
      <div>
<span class="Apple-tab-span"> </span>fix_nated_register();</div>
      <div>
<span class="Apple-tab-span"> </span>}
        else {</div>
      <div>
<span class="Apple-tab-span"> </span>fix_nated_contact();</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>setflag(FLT_NATS);</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#!endif</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>}</div>
      <div><br></div>
      <div># RTPProxy control</div>
      <div>route[NATMANAGE] {</div>
      <div>#!ifdef WITH_NAT</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_request()) {</div>
      <div>
<span class="Apple-tab-span"> </span>if(has_totag())
        {</div>
      <div>
<span class="Apple-tab-span"> </span>if(check_route_param("nat=yes"))
        {</div>
      <div>
<span class="Apple-tab-span"> </span>setbflag(FLB_NATB);</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!(isflagset(FLT_NATS) || isbflagset(FLB_NATB)))</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>
<span class="Apple-tab-span"> </span>rtpproxy_manage();</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_request()) {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!has_totag()) {</div>
      <div>
<span class="Apple-tab-span"> </span>add_rr_param(";nat=yes");</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_reply()) {</div>
      <div>
<span class="Apple-tab-span"> </span>if(isbflagset(FLB_NATB))
        {</div>
      <div>
<span class="Apple-tab-span"> </span>fix_nated_contact();</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#!endif</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>}</div>
      <div><br></div>
      <div># Routing to foreign domains</div>
      <div>route[SIPOUT] {</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (!uri==myself)</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>append_hf("P-hint:
        outbound\r\n");</div>
      <div>
<span class="Apple-tab-span"> </span>route(RELAY);</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>}</div>
      <div><br></div>
      <div>route[ACKBYE] {</div>
      <div>#!ifdef WITH_PSTN</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (is_method("BYE|ACK"))</div>
      <div>
<span class="Apple-tab-span"> </span>{</div>
      <div>
<span class="Apple-tab-span"> </span>xlog("L_ALERT","AB
        $rm $sht(forw=&gt;$ft) $td");</div>
      <div>
<span class="Apple-tab-span"> </span>if(($sht(forw=&gt;$ft))=~"MessageCPIM"){</div>
      <div># Direct messages between clients</div>
      <div>
<span class="Apple-tab-span"> </span>xlog("L_ALERT","AB
        $rm CPIM $td");</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if(src_ip==$td){</div>
      <div>#I have to rewrite du - messages loop in Kamailio</div>
      <div>
<span class="Apple-tab-span"> </span>xlog("L_ALERT","ACK,Bye
        Method equalIP");</div>
      <div>
<span class="Apple-tab-span"> </span>$du=$sht(forw=&gt;$ft);</div>
      <div>
<span class="Apple-tab-span"> </span>xlog("L_ALERT","ACK,Bye
        $ft $du");</div>
      <div>
<span class="Apple-tab-span"> </span>route(RELAY);</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>xlog("L_ALERT","ACK,Bye
        Not me");</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#!endif</div>
      <div>return;</div>
      <div>}</div>
      <div>route[PSTNINVITE] {</div>
      <div>
<span class="Apple-tab-span"> </span>if(is_method("INVITE")){</div>
      <div>
<span class="Apple-tab-span"> </span>if($rb=~"message/CPIM"){</div>
      <div># Direct messages between clients</div>
      <div>
<span class="Apple-tab-span"> </span>$sht(forw=&gt;$ft)="MessageCPIM";</div>
      <div>
<span class="Apple-tab-span"> </span>route(LOCATION);</div>
      <div>
<span class="Apple-tab-span"> </span>route(RELAY);</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#This way I can select from multiple Asterisk servers. I will
        t_relay instead of forward, because Asterisk servers are with
        local IP.</div>
      <div>
<span class="Apple-tab-span"> </span>ds_select_dst("1","4");</div>
      <div>
<span class="Apple-tab-span"> </span>$sht(forw=&gt;$ft)=$du;</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("100","Trying");</div>
      <div>
<span class="Apple-tab-span"> </span>route(RELAY);</div>
      <div>
<span class="Apple-tab-span"> </span>exit();</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>}</div>
      <div>route[PSTN] {</div>
      <div>#I am using this routine to forward to Asterisks (instead of
        additional one for balancing)</div>
      <div>#!ifdef WITH_PSTN</div>
      <div>
<span class="Apple-tab-span"> </span>#
        check if PSTN GW IP is defined</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (strempty($sel(cfg_get.pstn.gw_ip))) {</div>
      <div>
<span class="Apple-tab-span"> </span>xlog("SCRIPT:
        PSTN rotuing enabled but pstn.gw_ip not defined\n");</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if(allow_source_address())</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>
<span class="Apple-tab-span"> </span>if(from_uri!=myself)
        {</div>
      <div>
<span class="Apple-tab-span"> </span>sl_send_reply("403",
        "Not Allowed");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>
<span class="Apple-tab-span"> </span>if(is_method("MESSAGE"))</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>
<span class="Apple-tab-span"> </span>route(PSTNINVITE);</div>
      <div>
<span class="Apple-tab-span"> </span>route(RELAY);</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>#!endif</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>}</div>
      <div><br></div>
      <div><br></div>
      <div>
        # route to voicemail server</div>
      <div>route[TOVOICEMAIL] {</div>
      <div>
<span class="Apple-tab-span"> </span>return;</div>
      <div>}</div>
      <div><br></div>
      <div># manage outgoing branches</div>
      <div>branch_route[MANAGE_BRANCH] {</div>
      <div>
<span class="Apple-tab-span"> </span>xdbg("new
        branch [$T_branch_idx] to $ru\n");</div>
      <div>
<span class="Apple-tab-span"> </span>route(NATMANAGE);</div>
      <div>}</div>
      <div><br></div>
      <div># manage incoming replies</div>
      <div>onreply_route[MANAGE_REPLY] {</div>
      <div>
<span class="Apple-tab-span"> </span>xdbg("incoming
        reply\n");</div>
      <div>
<span class="Apple-tab-span"> </span>if(status=~"[12][0-9][0-9]")</div>
      <div>
<span class="Apple-tab-span"> </span>route(NATMANAGE);</div>
      <div>}</div>
      <div><br></div>
      <div># manage failure routing cases</div>
      <div>failure_route[MANAGE_FAILURE] {</div>
      <div>
<span class="Apple-tab-span"> </span>route(NATMANAGE);</div>
      <div><br></div>
      <div>
<span class="Apple-tab-span"> </span>if
        (t_is_canceled()) {</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div><br></div>
      <div>#!ifdef WITH_BLOCK3XX</div>
      <div>
<span class="Apple-tab-span"> </span>#
        block call redirect based on 3xx replies.</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (t_check_status("3[0-9][0-9]")) {</div>
      <div>
<span class="Apple-tab-span"> </span>t_reply("404","Not
        found");</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#!endif</div>
      <div><br></div>
      <div>#!ifdef WITH_VOICEMAIL</div>
      <div>
<span class="Apple-tab-span"> </span>#
        serial forking</div>
      <div>
<span class="Apple-tab-span"> </span>#
        - route to voicemail on busy or no answer (timeout)</div>
      <div>
<span class="Apple-tab-span"> </span>if
        (t_check_status("486|408")) {</div>
      <div>
<span class="Apple-tab-span"> </span>route(TOVOICEMAIL);</div>
      <div>
<span class="Apple-tab-span"> </span>exit;</div>
      <div>
<span class="Apple-tab-span"> </span>}</div>
      <div>#!endif</div>
      <div>}</div>
      <br><br>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@...">sr-users@...</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>

    </blockquote>
    <br>-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://linkedin.com/in/miconda">http://linkedin.com/in/miconda</a> -- <a class="moz-txt-link-freetext" href="http://twitter.com/miconda">http://twitter.com/miconda</a>
  </div>
Daniel-Constantin Mierla | 2 Jan 2012 12:03
Picon

Re: [SR-Users] Intermittent start up issue

Hello,

check also for limits in the system/firewall, maybe there are limits on new connections per second. Try with children=1 and see if it happens again, if not, then it is something that blocks many new connections in short time.

Cheers,
Daniel

On 1/2/12 5:31 AM, Sammy Govind wrote:
Hi,
Its all upto you then, that's an intermittent issue and information is not complete to trace the issue. Did you see the same Errors every time it fails !?

--
Regards
Sammy

On Sun, Jan 1, 2012 at 10:06 PM, Ali Jawad <ali.jawad-kFViwpaZTe3k1uMJSBkQmQ@public.gmane.org> wrote:
Hi
Thanks for your input, but as said this works at times yes and times
now so I am not sure it is a definite DB issue, the servers are in the
same LAN, and there are other modules that use the DB string that work
when launched before this one while this one does not work.
Regards

On Sun, Jan 1, 2012 at 4:13 PM, Sammy Govind <govoiper-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Hi,
> forget the whole list of errors and just resolve the DB connectivity between
> the Kamailio server and DB server first .
>
>> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> connect to MySQL server on 'xxxxxxxxx' (4)
>
>
> try connecting to the remote DB server 'xxxxxxxxx' from linux shell i.e
>
> # mysql -u<user> -p<passwd> -h 'xxxxxxxxx'
>
> Regards,
> Sammy
>
>
> On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad <ali.jawad-kFViwpaZTe3k1uMJSBkQmQ@public.gmane.org> wrote:
>>
>> Hi All
>> I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is
>> that Kamailio at times fails to start up for no obvious reasons, I.e.
>> in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug
>> log "level 2 " shows the following :
>>
>> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> connect to MySQL server on 'xxxxxxxxx' (4)
>> 27(24762) ERROR: <core> [db.c:303]: could not add connection to the
>> pool27(24762) ERROR: group [group.c:211]: unable to connect to the
>> database
>> 27(24762) ERROR: <core> [sr_module.c:889]: init_mod_child(): Error
>> while initializing module group
>> (/usr/local/kamailio/lib/kamailio/modules_k/group.so)
>> 27(24762) ERROR: <core> [pt.c:481]: ERROR: fork_tcp_process():
>> init_child failed for process 27, pid 24762, "tcp receiver child=1"
>>
>> and then
>>
>>
>> 30(24765) : <core> [pass_fd.c:293]: ERROR: receive_fd: EOF on 45
>>  0(24735) ALERT: <core> [main.c:748]: child process 24762 exited
>> normally, status=255
>>  0(24735) INFO: <core> [main.c:766]: INFO: terminating due to SIGCHLD
>>
>> The problem happens on 4 different servers, I did try to compile more
>> than once, the servers are 32 Bit CentOS 5.6. The connection to the
>> database is monitored and there are no issues with connecting to the
>> DB "it works at times and times not for Kamailio so a user/pwd issue
>> is not likely to cause this, manual cnnect worked", config file errors
>> are not found.
>>
>> I did also check max no of connections on MySQL server which is set to
>> 500 on the server and only 100 cons are used. The group module uses
>> the same connection string as other modules  which is predefined  and
>> there are other modules that access the db before the group module and
>> those do not have a problem.
>>
>> Please advice.
>>
>> Regards
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+b@public.gmane.org
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+b@public.gmane.org
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>



--
Ali Jawad
Information Systems Manager
Splendor Telecom (www.splendor.net)
Beirut, Lebanon
Phone: +9611373725/ext 116
FAX: +9611375554

_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
sr-users-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+b@public.gmane.org
http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users



_______________________________________________ SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users-cR8azDVoa3IcDhw6gZKtMWD2FQJk+8+b@public.gmane.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

-- Daniel-Constantin Mierla -- http://www.asipto.com http://linkedin.com/in/miconda -- http://twitter.com/miconda
<div>
    Hello,<br><br>
    check also for limits in the system/firewall, maybe there are limits
    on new connections per second. Try with children=1 and see if it
    happens again, if not, then it is something that blocks many new
    connections in short time.<br><br>
    Cheers,<br>
    Daniel<br><br>
    On 1/2/12 5:31 AM, Sammy Govind wrote:
    <blockquote cite="mid:CAJUJwti3dcrPtRZRaTSfhXu59c9rHsiRYQdJUVFWF2=vaqYQWQ@..." type="cite">Hi,
      <div>Its all upto you then,&nbsp;that's&nbsp;an intermittent issue and
        information is not complete to trace the issue. Did you see the
        same Errors&nbsp;every time&nbsp;it fails !?</div>
      <div><br></div>
      <div>--</div>
      <div>Regards</div>
      <div>
        Sammy<br><br><div class="gmail_quote">On Sun, Jan 1, 2012 at 10:06 PM, Ali
          Jawad <span dir="ltr">&lt;<a moz-do-not-send="true" href="mailto:ali.jawad@...">ali.jawad@...</a>&gt;</span>
          wrote:<br><blockquote class="gmail_quote">
            Hi<br>
            Thanks for your input, but as said this works at times yes
            and times<br>
            now so I am not sure it is a definite DB issue, the servers
            are in the<br>
            same LAN, and there are other modules that use the DB string
            that work<br>
            when launched before this one while this one does not work.<br>
            Regards<br><div class="HOEnZb">
              <div class="h5">
<br>
                On Sun, Jan 1, 2012 at 4:13 PM, Sammy Govind &lt;<a moz-do-not-send="true" href="mailto:govoiper@...">govoiper@...</a>&gt;
                wrote:<br>
                &gt; Hi,<br>
                &gt; forget the whole list of errors and just resolve
                the DB connectivity between<br>
                &gt; the Kamailio server and DB server first .<br>
                &gt;<br>
                &gt;&gt; 27(24762) ERROR: db_mysql [km_my_con.c:109]:
                driver error: Can't<br>
                &gt;&gt; connect to MySQL server on 'xxxxxxxxx' (4)<br>
                &gt;<br>
                &gt;<br>
                &gt; try connecting to the remote DB server&nbsp;'xxxxxxxxx'
                from linux shell i.e<br>
                &gt;<br>
                &gt; # mysql -u&lt;user&gt; -p&lt;passwd&gt;
                -h&nbsp;'xxxxxxxxx'<br>
                &gt;<br>
                &gt; Regards,<br>
                &gt; Sammy<br>
                &gt;<br>
                &gt;<br>
                &gt; On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad &lt;<a moz-do-not-send="true" href="mailto:ali.jawad@...">ali.jawad@...</a>&gt;
                wrote:<br>
                &gt;&gt;<br>
                &gt;&gt; Hi All<br>
                &gt;&gt; I have tried the below with Kamailio 3.1.0 and
                3.2.1. the problem is<br>
                &gt;&gt; that Kamailio at times fails to&nbsp;start up&nbsp;for no
                obvious reasons, I.e.<br>
                &gt;&gt; in 10 restarts Kamailio might fail to start 3,0
                or 5 times. Te debug<br>
                &gt;&gt; log "level 2 " shows the following :<br>
                &gt;&gt;<br>
                &gt;&gt; 27(24762) ERROR: db_mysql [km_my_con.c:109]:
                driver error: Can't<br>
                &gt;&gt; connect to MySQL server on 'xxxxxxxxx' (4)<br>
                &gt;&gt; 27(24762) ERROR: &lt;core&gt; [db.c:303]: could
                not add connection to the<br>
                &gt;&gt; pool27(24762) ERROR: group [group.c:211]:
                unable to connect to the<br>
                &gt;&gt; database<br>
                &gt;&gt; 27(24762) ERROR: &lt;core&gt;
                [sr_module.c:889]: init_mod_child(): Error<br>
                &gt;&gt; while initializing module group<br>
                &gt;&gt;
                (/usr/local/kamailio/lib/kamailio/modules_k/group.so)<br>
                &gt;&gt; 27(24762) ERROR: &lt;core&gt; [pt.c:481]:
                ERROR: fork_tcp_process():<br>
                &gt;&gt; init_child failed for process 27, pid 24762,
                "tcp receiver child=1"<br>
                &gt;&gt;<br>
                &gt;&gt; and then<br>
                &gt;&gt;<br>
                &gt;&gt;<br>
                &gt;&gt; 30(24765) : &lt;core&gt; [pass_fd.c:293]:
                ERROR: receive_fd: EOF on 45<br>
                &gt;&gt; &nbsp;0(24735) ALERT: &lt;core&gt; [main.c:748]:
                child process 24762 exited<br>
                &gt;&gt; normally, status=255<br>
                &gt;&gt; &nbsp;0(24735) INFO: &lt;core&gt; [main.c:766]:
                INFO: terminating due to SIGCHLD<br>
                &gt;&gt;<br>
                &gt;&gt; The problem happens on 4 different servers, I
                did try to compile more<br>
                &gt;&gt; than once, the servers are 32 Bit CentOS 5.6.
                The connection to the<br>
                &gt;&gt; database is monitored and there are no issues
                with connecting to the<br>
                &gt;&gt; DB "it works at times and times not for
                Kamailio so a user/pwd issue<br>
                &gt;&gt; is not likely to cause this, manual cnnect
                worked", config file errors<br>
                &gt;&gt; are not found.<br>
                &gt;&gt;<br>
                &gt;&gt; I did also check max no of connections on MySQL
                server which is set to<br>
                &gt;&gt; 500 on the server and only 100&nbsp;cons&nbsp;are used.
                The group module uses<br>
                &gt;&gt; the same connection string as other modules
                &nbsp;which is predefined &nbsp;and<br>
                &gt;&gt; there are other modules that access the db
                before the group module and<br>
                &gt;&gt; those do not have a problem.<br>
                &gt;&gt;<br>
                &gt;&gt; Please advice.<br>
                &gt;&gt;<br>
                &gt;&gt; Regards<br>
                &gt;&gt;<br>
                &gt;&gt; _______________________________________________<br>
                &gt;&gt; SIP Express Router (SER) and Kamailio (OpenSER)
                - sr-users mailing list<br>
                &gt;&gt; <a moz-do-not-send="true" href="mailto:sr-users@...">sr-users@...</a><br>
                &gt;&gt; <a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
                &gt;<br>
                &gt;<br>
                &gt;<br>
                &gt; _______________________________________________<br>
                &gt; SIP Express Router (SER) and Kamailio (OpenSER) -
                sr-users mailing list<br>
                &gt; <a moz-do-not-send="true" href="mailto:sr-users@...">sr-users@...</a><br>
                &gt; <a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
                &gt;<br><br><br><br>
</div>
            </div>
            <span class="HOEnZb">--<br>
                Ali Jawad<br>
                Information Systems Manager<br>
                Splendor Telecom (<a moz-do-not-send="true" href="http://www.splendor.net" target="_blank">www.splendor.net</a>)<br>
                Beirut, Lebanon<br>
                Phone: <a moz-do-not-send="true" href="tel:%2B9611373725" value="+9611373725">+9611373725</a>/ext
                116<br>
                FAX: <a moz-do-not-send="true" href="tel:%2B9611375554" value="+9611375554">+9611375554</a><br></span>
            <div class="HOEnZb">
              <div class="h5">
<br>
                _______________________________________________<br>
                SIP Express Router (SER) and Kamailio (OpenSER) -
                sr-users mailing list<br><a moz-do-not-send="true" href="mailto:sr-users@...">sr-users@...</a><br><a moz-do-not-send="true" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users" target="_blank">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a><br>
</div>
            </div>
          </blockquote>
        </div>
        <br>
</div>
      <br><br>_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@...">sr-users@...</a>
<a class="moz-txt-link-freetext" href="http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users">http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users</a>

    </blockquote>
    <br>-- 
Daniel-Constantin Mierla -- <a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a>
<a class="moz-txt-link-freetext" href="http://linkedin.com/in/miconda">http://linkedin.com/in/miconda</a> -- <a class="moz-txt-link-freetext" href="http://twitter.com/miconda">http://twitter.com/miconda</a>
  </div>
Daniel-Constantin Mierla | 2 Jan 2012 12:07
Picon

Re: [SR-Users] No memory left in send_subscribe (PUA) from update_pua while building the tm dlg_t structure

Hello,

On 12/29/11 7:06 PM, laura testi wrote:
> Hi Daniel,
> yes we are running 3.1.5, but we have back ported the whole pua module
> from the master branch that included also the patches in your link. In
> fact, the second patch use the patches from the link you have
> mentioned to solve the same problem. Because the patches themselves
> from the link  (http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=b93149c756d3e983c70608938f1142ed43ee1834)
> are not enough for the PUA_XMPP module.
ok, checking for side effects was the reason not to go ahead with the 
patch immediately. I was looking and the is_dialog function seems to be 
used just by other modules, not by pua itself: pua_bla, pua_xmpp and 
purple. I think it is safe to go ahead with it, maybe in a different 
form, like returning different values when it is established or 
temporary dialog, eventually with an extra parameter to specify which 
kind of dialogs should be searched -- this needs a bit of analyze to 
choose the best.

Cheers,
Daniel

>
> The same problem is true both for RLS and for PUA_XMPP. The real
> problem is that for some strange reason (I don't know why), the
> PUA_XMPP receive/process the NOTIFY message received from kamailio
> presence server before the 200OK of the SUBSCRIBE. That's why the
> previous patched implement the temporary dialog to avoid it. But it's
> not enough, at least for PUA_XMPP.
>
> If you have a look at the line 196 inside the function
> Notify2Xmpp(struct sip_msg* msg, char* s1, char* s2) in the file
> modules_k/pua_xmpp/simple2xmpp.c:
>
>   196         if(pua_is_dialog(&dialog)<  0) // verify if within a stored dialog
>   197         {
>   198                 LM_ERR("Notify in a non existing dialog\n");
>   199                 goto error;
>   200         }
>
> In this case, the PUA_XMPP will print the Error and does not process
> the NOTIFY message (convert it to XMPP and send it out to the XMPP
> domain). And we got a lot of error "Notify in a non existing dialog"
> in the log file. After we applied the patches from the link, the
> errors are still there, because the pua_is_dialog call the function
> is_dialog defined in the hash.c in the pua module, without the second
> patch of hash.c, it will still return -1 because is_dialog checks the
> dialog only against the real dialog in the hash, but not the temporary
> one. After we have applied the patch in the is_dialog function. The
> error is gone ;-) But I don't know if this may have impact on other
> modules. I means I don't know if there are some modules use this
> function to check if the only real dialog (but not temporary dialog)
> is existing in the hash. In this case maybe is better to have 2 check
> functions, one for real, another for both or temporary. What do you
> think?
>
>
> Best Regards,
> Laura
>
>
>
>
>
>
>
> But the patches
>
> Yes, the second
>
>
>
> On Thu, Dec 29, 2011 at 4:41 PM, Daniel-Constantin Mierla
> <miconda@...>  wrote:
>> Hello Laura,
>>
>> I applied most of the patches, apart the second one for hash.c, related to
>> checking for temporary dialog. I need to look a bit more at it, since there
>> was some work in this regard:
>>
>> http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commitdiff;h=b93149c756d3e983c70608938f1142ed43ee1834
>>
>> If I understood right, it is about NOTIFY getting processed faster than
>> 200OK for SUBSCRIBE. Do I remember correctly, you are running 3.1.x? It
>> might not be in branch 3.1.
>>
>> Cheers,
>> Daniel
>>
>>
>> On 12/28/11 6:15 PM, laura testi wrote:
>>
>> Hi Daniel,
>> Yes, all patches are related to the PUA module. Please find the
>> attachments for both diff files and new files with applied patches If
>> you thinks they are useful. Now the old files should be the latest
>> version of the master branch ;-) Unfortunately I can not use git here.
>> We have tested the patches, now no memory leak any more; and no more
>> error for NOTIFY (dialog not found)...Please note, our use case is the
>> pua_xmpp, now it works fine. I don't know if rls has the same problem.
>> Thank you veru much for your helps again.
>>
>> Some explanations:
>>
>> In the send_subscribe.c,
>>    - I just comment out the line 1172 so that the pua_free_tm_dlg(td)
>> do the right job later as you done also in this case.
>>
>> In the hash.c,
>>    - in the get_dialog function, I add the check of "p->to_tag.len>  0"
>> in the string compare conditions;
>>
>>    - in the is_dialog function, instead of check only the real dialog,
>> the check of also the temporary dialog is added, this also helps to
>> avoid the error of no dialog found for the NOTIFY if the NOTIFY is
>> received before the 202/200 OK of the SUBSCRIBE.
>>
>> in the pua.c,
>>    -   a few changes in  the update_pua function:
>>       - apply the same kind of free td and td->route_set, unfortunately
>> I can not re-use pua_free_tm_dlg which is local for send_subscribe.c.
>>       - change from goto error to goto done
>>
>>
>> Best Regards,
>> Laura
>>
>>
>>
>> On Wed, Dec 28, 2011 at 2:39 PM, Daniel-Constantin Mierla
>> <miconda@...>  wrote:
>>
>> Hello,
>>
>>
>> On 12/27/11 1:51 PM, laura testi wrote:
>>
>> Hi Daniel,
>> I tried the patch, it works partially. There are stil memory leak.
>> Based on your patch, I did find different places need the same kind of
>> patch both in send_subscribe,c and in pua,c
>>
>>
>> ok, thanks, I will look over. But how did you do the patches, since it does
>> not take my latest patch, seems to be against an older version, because the
>> indentation is not there?
>>
>> I cannot apply it like this, maybe you can tell the files and lines you
>> changed, otherwise is hard to track.
>>
>> Are both patches to the pua module? You are doing the patch with files only,
>> it is more convenient to call the diff with path to the module, in this way
>> is easy to spot in which module to apply the path -- i.e., use diff from
>> root folder of kamailio, like:
>>
>> diff -u modules/abc/oldfile modules/abc/newfile
>>
>> Since you are sending a lot of patches, maybe it will work better if you
>> just clone the git, make the patch against the master branch -- change the
>> file in the master branch and then just do:
>>
>> git diff>  path/to/save/patch.file
>>
>> Some info that could be useful for working with git and patches, including
>> backporting, at:
>>
>> http://www.kamailio.org/wiki/devel/backporting-to-3.2.x
>>
>> Cheers,
>> Daniel
>>
>>
>>
>>
>> Please find the modified version of these files.
>>
>> Following are the differences:
>> # diff -u send_subscribe.c.orig send_subscribe.c
>> --- send_subscribe.c.orig       2011-12-27 13:31:06.000000000 +0100
>> +++ send_subscribe.c    2011-12-27 13:31:51.000000000 +0100
>>  <at>  <at>  -1151,7 +1151,6  <at>  <at> 
>>                          if (dbmode!=PUA_DB_ONLY)
>>
>> lock_release(&HashT->p_records[hash_code].lock);
>>                          ret= -1;
>> -                       pkg_free(td);
>>                          goto done;
>>                  }
>>                  if (dbmode!=PUA_DB_ONLY)
>>
>>
>>
>>
>>
>> # diff -u pua.c.orig pua.c
>> --- pua.c.orig  2011-12-27 13:15:47.000000000 +0100
>> +++ pua.c       2011-12-27 13:26:33.000000000 +0100
>>  <at>  <at>  -673,106 +673,145  <at>  <at> 
>>
>>   int update_pua(ua_pres_t* p)
>>   {
>> -       str* str_hdr= NULL;
>> -       int expires;
>> -       int result;
>> -       uac_req_t uac_r;
>> -
>> -       if(p->desired_expires== 0)
>> -               expires= 3600;
>> -       else
>> -               expires= p->desired_expires- (int)time(NULL);
>> +  str* str_hdr= NULL;
>> +  ua_pres_t* cb_param = NULL;
>>
>> -       if(p->watcher_uri== NULL)
>> -       {
>> -               str met= {"PUBLISH", 7};
>> -               ua_pres_t* cb_param;
>> -
>> -               str_hdr = publ_build_hdr(expires, get_event(p->event), NULL,
>> -&p->etag, p->extra_headers, 0);
>> -               if(str_hdr == NULL)
>> -               {
>> -                       LM_ERR("while building extra_headers\n");
>> -                       goto error;
>> -               }
>> -               LM_DBG("str_hdr:\n%.*s\n ", str_hdr->len, str_hdr->s);
>> -
>> -               cb_param= build_uppubl_cbparam(p);
>> -               if(cb_param== NULL)
>> -               {
>> -                       LM_ERR("while constructing publ callback param\n");
>> -                       goto error;
>> -               }
>> -
>> -               set_uac_req(&uac_r,&met, str_hdr, 0, 0,
>> TMCB_LOCAL_COMPLETED,
>> -                               publ_cback_func, (void*)cb_param);
>> -
>> -               result= tmb.t_request(&uac_r,
>> -                               p->pres_uri,
>>          /* Request-URI */
>> -                               p->pres_uri,
>>          /* To */
>> -                               p->pres_uri,
>>          /* From */
>> -&outbound_proxy
>>          /* Outbound proxy*/
>> -                               );
>> -               if(result<  0)
>> -               {
>> -                       LM_ERR("in t_request function\n");
>> -                       shm_free(cb_param);
>> -                       goto error;
>> -               }
>> -
>> -       }
>> -       else
>> -       {
>> -               str met= {"SUBSCRIBE", 9};
>> -               dlg_t* td= NULL;
>> -               ua_pres_t* cb_param= NULL;
>> -
>> -               td= pua_build_dlg_t(p);
>> -               if(td== NULL)
>> -               {
>> -                       LM_ERR("while building tm dlg_t structure");
>> -                       goto error;
>> -               };
>> -
>> -               str_hdr= subs_build_hdr(&p->contact,
>> expires,p->event,p->extra_headers);
>> -               if(str_hdr== NULL || str_hdr->s== NULL)
>> -               {
>> -                       LM_ERR("while building extra headers\n");
>> -                       pkg_free(td);
>> -                       return -1;
>> -               }
>> -               cb_param= subs_cbparam_indlg(p, expires, REQ_ME);
>> -               if(cb_param== NULL)
>> -               {
>> -                       LM_ERR("while constructing subs callback param\n");
>> -                       goto error;
>> -
>> -               }
>> -
>> -               set_uac_req(&uac_r,&met, str_hdr, 0, td,
>> TMCB_LOCAL_COMPLETED,
>> -                               subs_cback_func, (void*)cb_param);
>> -
>> -               result= tmb.t_request_within(&uac_r);
>> -               if(result<  0)
>> -               {
>> -                       LM_ERR("in t_request function\n");
>> -                       shm_free(cb_param);
>> -                       pkg_free(td);
>> -                       goto error;
>> -               }
>> -
>> -               pkg_free(td);
>> -               td= NULL;
>> -       }
>> -
>> -       pkg_free(str_hdr);
>> -       return 0;
>> -
>> -error:
>> -       if(str_hdr)
>> -               pkg_free(str_hdr);
>> -       return -1;
>> +  int expires;
>> +  int result = 0;
>> +  uac_req_t uac_r;
>> +  str met = {NULL, 0};
>> +  int ret_code = 0;
>> +  dlg_t* td = NULL;
>> +
>> +
>> +  if(p->desired_expires== 0)
>> +    expires= default_expires;
>> +  else
>> +    expires= p->desired_expires- (int)time(NULL);
>> +
>> +  if(p->watcher_uri== NULL)
>> +  {
>> +
>> +    str_hdr = publ_build_hdr(expires, get_event(p->event), NULL,
>> +&p->etag, p->extra_headers, 0);
>> +
>> +    if(str_hdr == NULL)
>> +    {
>> +      LM_ERR("while building extra_headers\n");
>> +      ret_code = -1;
>> +      goto done;
>> +    }
>> +    LM_DBG("str_hdr:\n%.*s\n ", str_hdr->len, str_hdr->s);
>> +
>> +    cb_param= build_uppubl_cbparam(p);
>> +    if(cb_param== NULL)
>> +    {
>> +      LM_ERR("while constructing publ callback param\n");
>> +      ret_code = -1;
>> +      goto done;
>> +    }
>> +
>> +    met.s =  (char*)pkg_malloc(8*sizeof(char));
>> +    if(met.s == NULL) {
>> +      LM_ERR("no memory for met.s(PUBLISH)\n");
>> +      ret_code = -1;
>> +      goto done;
>> +    }
>> +    memset(met.s, 0, 8);
>> +    memcpy(met.s, "PUBLISH", 7);
>> +    met.len = 7;
>> +    set_uac_req(&uac_r,&met, str_hdr, 0, 0, TMCB_LOCAL_COMPLETED,
>> +        publ_cback_func, (void*)cb_param);
>> +
>> +    result= tmb.t_request(&uac_r,
>> +        p->pres_uri,          /* Request-URI */
>> +        p->pres_uri,          /* To */
>> +        p->pres_uri,          /* From */
>> +&outbound_proxy         /* Outbound proxy*/
>> +        );
>> +    if(result<  0)
>> +    {
>> +      LM_ERR("in t_request function\n");
>> +      shm_free(cb_param);
>> +      cb_param = NULL;
>> +      ret_code = -1;
>> +      goto done;
>> +    }
>> +  }
>> +  else
>> +  {
>> +    td= pua_build_dlg_t(p);
>> +    if(td== NULL)
>> +    {
>> +      LM_ERR("while building tm dlg_t structure");
>> +      ret_code = -1;
>> +      goto done;
>> +    };
>> +
>> +    str_hdr= subs_build_hdr(&p->contact,
>> expires,p->event,p->extra_headers);
>> +    if(str_hdr== NULL || str_hdr->s== NULL)
>> +    {
>> +      if(p->event!=0)
>> +        LM_ERR("while building extra headers\n");
>> +
>> +      ret_code = -1;
>> +      goto done;
>> +    }
>> +
>> +    cb_param= subs_cbparam_indlg(p, expires, REQ_ME);
>> +    if(cb_param== NULL)
>> +    {
>> +      LM_ERR("while constructing subs callback param\n");
>> +      ret_code = -1;
>> +      goto done;
>> +    }
>> +
>> +    met.s =  (char*)pkg_malloc(10*sizeof(char));
>> +    if(met.s == NULL) {
>> +      LM_ERR("no memory for met.s(SUBSCRIBE)\n");
>> +      ret_code = -1;
>> +      goto done;
>> +    }
>> +    memset(met.s, 0, 10);
>> +    memcpy(met.s, "SUBSCRIBE", 9);
>> +    met.len = 9;
>> +    set_uac_req(&uac_r,&met, str_hdr, 0, td, TMCB_LOCAL_COMPLETED,
>> +    subs_cback_func, (void*)cb_param);
>> +
>> +    result= tmb.t_request_within(&uac_r);
>> +    if(result<  0)
>> +    {
>> +      LM_ERR("in t_request function\n");
>> +      ret_code = -1;
>> +      shm_free(cb_param);
>> +      cb_param = NULL;
>> +      goto done;
>> +    }
>> +  }
>> +
>> +
>> +done:
>> +  if(td!=NULL)
>> +  {
>> +   if(td->route_set)
>> +      free_rr(&td->route_set);
>> +
>> +    pkg_free(td);
>> +    td= NULL;
>> +  }
>> +
>> +  if(met.s != NULL) {
>> +    pkg_free(met.s);
>> +    met.s = NULL;
>> +    met.len = 0;
>> +  }
>> +
>> +  if(str_hdr != NULL) {
>> +    pkg_free(str_hdr);
>> +    str_hdr = NULL;
>> +  }
>>
>> +  return ret_code;
>>   }
>>
>>   static void db_update(unsigned int ticks,void *param)
>>
>>
>> It seems a lot of change, but there are only a few lines changed,
>> probably in the file I modify I have convert the TAB to Space and the
>> diff does not recognize them. Another thing is I use dynamic memory
>> for the str SUBSCRIBE and PUBLISH.
>>
>>
>>
>>
>> Another thing for the management of NOTIFY arrives before the 202/200
>> OK of SUBSCRIBE, in addition to the patches done previously, maybe the
>> hash.c need to patch for the is_dialog function which is called for
>> the NOTIFY in PUA_XMPP module:
>>
>> # diff -u hash.c.orig hash.c
>> --- hash.c.orig 2011-12-27 13:38:06.000000000 +0100
>> +++ hash.c      2011-12-27 13:38:38.000000000 +0100
>>  <at>  <at>  -487,10 +487,11  <at>  <at> 
>>          hash_code= core_hash(dialog->pres_uri, dialog->watcher_uri,
>> HASH_SIZE);
>>          lock_get(&HashT->p_records[hash_code].lock);
>>
>> -       if(get_dialog(dialog, hash_code)== NULL)
>> -               ret_code= -1;
>> -       else
>> +       if(get_dialog(dialog, hash_code) ||
>> get_temporary_dialog(dialog, hash_code))
>>                  ret_code= 0;
>> +       else
>> +               ret_code= -1;
>> +
>>          lock_release(&HashT->p_records[hash_code].lock);
>>
>>          return ret_code;
>>
>>
>> Best Regards,
>> Laura
>>
>> On Fri, Dec 23, 2011 at 5:10 PM, laura testi<lau.testi@...>  wrote:
>>
>> Ok, I'll try it.
>>
>> Thank you very much!
>>
>>
>>
>>
>> On Fri, Dec 23, 2011 at 1:20 PM, Daniel-Constantin Mierla
>> <miconda@...>  wrote:
>>
>> Hello,
>>
>> can you try with this patch:
>>
>> http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=1b3cfa60a5b5c7d435704d44b7c495b7e6aa84c8
>>
>> Cheers,
>> Daniel
>>
>>
>> On 12/23/11 12:36 PM, Daniel-Constantin Mierla wrote:
>>
>> Hello,
>>
>> looks like a leak in a module that is storing record-routes and use them
>> later, perhaps pua module, I will check it soon.
>>
>> Cheers,
>> Daniel
>>
>> On 12/23/11 11:31 AM, laura testi wrote:
>>
>> Hi Daniel,
>> I just follow the instruction in the link you sent
>> (http://www.asipto.com/pub/kamailio-devel-guide/#c04troubleshooting)
>> to use gdb to print PKG fragments. When I got the error in PUA:
>>
>> Dec 23 11:10:53 /.../sbin/kamailio[23276]: ERROR: pua
>> [send_subscribe.c:158]: No memory left for size:439
>> Dec 23 11:10:53 /.../sbin/kamailio[23276]: ERROR: pua [pua.c:747]:
>> while building tm dlg_t structure
>> Dec 23 11:10:53 /.../sbin/kamailio[23276]: ERROR: pua [pua.c:652]:
>> while updating record
>>
>>
>> The I run the command
>> gdb /.../sbin/kamailio 23276
>> and write the following commands in the gdb:
>>
>> set $i=0
>> set $a = mem_block->first_frag
>> while($i<10000)
>>    if($i>2000)
>>      if($a->u.is_free==0)
>>        p *$a
>>      end
>>    end
>>    set $a = ((struct qm_frag*)((char*)($a)+sizeof(struct
>> qm_frag)+((struct qm_frag*)$a)->size+sizeof(struct qm_frag_end)))
>>    set $i = $i + 1
>> end
>> ...
>>
>> after a while I got a lot of prints on the screen like these:
>>
>>    func = 0x5d7b00 "do_parse_rr_body", line = 74, check = 4042322160}
>> $1348 = {size = 72, u = {nxt_free = 0x0, is_free = 0},
>>    file = 0x5d76c9 "<core>: parser/parse_rr.c",
>>    func = 0x5d7b00 "do_parse_rr_body", line = 74, check = 4042322160}
>> $1349 = {size = 72, u = {nxt_free = 0x0, is_free = 0},
>>    file = 0x5d76c9 "<core>: parser/parse_rr.c",
>>    func = 0x5d7b00 "do_parse_rr_body", line = 74, check = 4042322160}
>> $1350 = {size = 72, u = {nxt_free = 0x0, is_free = 0},
>>    file = 0x5d76c9 "<core>: parser/parse_rr.c",
>>    func = 0x5d7b00 "do_parse_rr_body", line = 74, check = 4042322160}
>> $1351 = {size = 104, u = {nxt_free = 0x0, is_free = 0},
>>    file = 0x5d76c9 "<core>: parser/parse_rr.c",
>>    func = 0x5d7b00 "do_parse_rr_body", line = 74, check = 4042322160}
>> $1352 = {size = 104, u = {nxt_free = 0x0, is_free = 0},
>>    file = 0x5d76c9 "<core>: parser/parse_rr.c",
>>    func = 0x5d7b00 "do_parse_rr_body", line = 74, check = 4042322160}
>> $1353 = {size = 72, u = {nxt_free = 0x0, is_free = 0},
>>    file = 0x5d76c9 "<core>: parser/parse_rr.c",
>>    func = 0x5d7b00 "do_parse_rr_body", line = 74, check = 4042322160}
>> $1354 = {size = 72, u = {nxt_free = 0x0, is_free = 0},
>> ---Type<return>    to continue, or q<return>    to quit---
>>
>> ...
>>
>>
>> But I don't understand if these are normal or something goes wrong....
>>
>> Can you help
>>
>>
>> Best Regards,
>> Laura
>>
>> On Wed, Dec 21, 2011 at 12:18 PM, Daniel-Constantin Mierla
>> <miconda@...>    wrote:
>>
>> Hello,
>>
>> pkg.stats was added in 3.2.0, iirc. For 3.1, you can walk the packets in
>> memory with gdb -- 3.1 has memory debug on, so you don't need to
>> recompile
>> (unless you turned it off).
>>
>> Just attach to the pid of a sip worker  (gdb /path/to/kamailio
>> _pid_value_)
>> and run the gdb script.
>>
>> Cheers,
>> Daniel
>>
>>
>> On 12/21/11 11:58 AM, laura testi wrote:
>>
>> Hi Daniel,
>> I try the sercmd for pkg memory but it return 500 error:
>>
>>
>> # sercmd
>> sercmd 0.2
>> Copyright 2006 iptelorg GmbH
>> This is free software with ABSOLUTELY NO WARRANTY.
>> For details type `warranty'.
>> sercmd>      pkg.stats
>> error: 500 - command pkg.stats not found
>> sercmd>
>>
>>
>>
>> Is it available only for 3.2.x and master branch? Because we are using
>> 3.1.5. But take the PUA module from master branch for the fetch_row
>> parameter you have patched ;-)
>>
>>
>> core.shmmem is ok.
>>
>>
>>
>> Thanks a lot
>>
>> Laura
>>
>> On Wed, Dec 21, 2011 at 10:58 AM, Daniel-Constantin Mierla
>> <miconda@...>      wrote:
>>
>> Hello,
>>
>> you can see the available pkg via sercmd, sending command pkg.stats
>> (match
>> the entry for the pid printing the error). If there is no free memory,
>> then
>> might be a leak.
>>
>> You can attach with gdb to the pid printing these errors and walk to
>> pkg,
>> you see the commands for gdb at:
>>
>> http://www.asipto.com/pub/kamailio-devel-guide/#c04troubleshooting
>>
>> See if you have lot of allocated chunks from same place in source code
>> (ignore those at the beginning, mainly related to cfg parsing) and
>> send
>> the
>> details here.
>>
>> Cheers,
>> Daniel
>>
>>
>> On 12/21/11 10:44 AM, laura testi wrote:
>>
>> Hi,
>> we are using the PUA_XMPP and PUA modules from the master branch. When
>> the modules are started, everything are ok, the presence events from
>> XMPP are sent to kamailio SIP servers (PUBLISH/SUBSCRIBE) and cached
>> in the hash. But when there are several thousands records in the hash
>> tabel, the update_pua function called in the hashT_clean gives a lot
>> of "No memory left" error when the hashT_clean is waked up from the
>> time:
>>
>> ERROR: pua [send_subscribe.c]: No memory left
>> ERROR: pua [pua.c]: while building tm dlg_t structure
>>
>> The failed call is:
>>         td = (dlg_t*)pkg_malloc(size);
>>         if(td == NULL)
>>         {
>>                 LM_ERR("No memory left\n");
>>                 return NULL;
>>         }
>>
>> in dlg_t* pua_build_dlg_t(ua_pres_t* presentity) function in
>> send_subscribe.c. The size is about 400 and something... It's
>> strange.....
>>
>> Is it the memory leak in the PUA module?
>>
>>
>>
>> I also try to increase the pkg_memory from 4MB default to 16MB, but it
>> doesn't help.
>>
>>
>> Any Idea?
>>
>> Thanks in advanced
>>
>> Laura
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing
>> list
>> sr-users@...
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>> --
>> Daniel-Constantin Mierla -- http://www.asipto.com
>> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users@...
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>> --
>> Daniel-Constantin Mierla -- http://www.asipto.com
>> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>>
>> --
>> Daniel-Constantin Mierla -- http://www.asipto.com
>> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>>
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users@...
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>> --
>> Daniel-Constantin Mierla -- http://www.asipto.com
>> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>>
>>
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users@...
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>>
>>
>> --
>> Daniel-Constantin Mierla -- http://www.asipto.com
>> http://linkedin.com/in/miconda -- http://twitter.com/miconda
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users@...
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users

--

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda

Daniel-Constantin Mierla | 2 Jan 2012 12:20
Picon

Re: [SR-Users] usrloc, timer process and cache cleanup

Hello,

On 12/23/11 1:39 PM, Andreas Granig wrote:
> Hi,
>
> On 12/23/2011 12:28 AM, Daniel-Constantin Mierla wrote:
>>> If someone is messing with the db, kamailio shouldn't try to correct
>>> admin mistakes.
>> It was just an example, I haven't gone to all corner cases that can
>> happen from human or (self or different) application errors. There were
>> couple of similar reports in the past, related to conflicts of
>> insert/update, update/insert, delete/update a.s.o. cases, so I proposed
>> to go for a portable solution, not for one which valid to a db driver
>> only -- configurable or not, is different thing than the specific topic.
> Of course you can never rule out admin errors or application errors, but
> anyways I'll highly favor a more resilient approach.

I encountered several cases when things can go bad at database layer 
while doing cross replication along with t_replicate(). Finding a 
solution would be a good thing. The fact is that these situations should 
be corner cases, so there has to be a solution not impact the normal 
operation mode.
>
> I've tried to reproduce the most obvious scenario, which is registering
> a subscriber, delete it from the underlying db table, then re-register
> again. The expiry value in the cache is refreshed, but it's never
> written back to the db table. There are most likely other, more subtle
> scenarios, and our customers approved that they didn't mess with the db
> manually. The state was always CS_SYNC and Flags was 0.
>
> I don't know the details of the srdb layer, but probably it's possible
> to find a way to return the "rows affected" after an update in order to
> know whether to try an insert afterwards. Would be possible with mysql,
> not sure about pgsql, oracle, dbtext etc. We'll take a look how we could
> tackle that.
Mysql has affected row and it is exported by db_mysql module, not sure 
about the other drivers.

>
> I don't think that a log message would help very much, because kamailio
> won't know about the missing entry in the db (unless you evaluate the
> result of the update), at least in this particular case.
Yes, kamailio does not know, I know, seems it is what we try to solve -- 
first how to make it aware and then do some actions (like writing a log 
message).

Perhaps the best for the moment is to detect at startup and rely on db 
api capabilities and use replace/affected_rows a.s.o. when they are 
available, in the best efficient order -- a module parameter can give 
admins the power to decide over the auto-detect.

Cheers,
Daniel

--

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda

Ali Jawad | 2 Jan 2012 12:24

Re: [SR-Users] Intermittent start up issue

When it fails I see the same errors yes. Thanks !

On Mon, Jan 2, 2012 at 7:31 AM, Sammy Govind <govoiper@...> wrote:
> Hi,
> Its all upto you then, that's an intermittent issue and information is not
> complete to trace the issue. Did you see the same Errors every time it fails
> !?
>
> --
> Regards
> Sammy
>
>
> On Sun, Jan 1, 2012 at 10:06 PM, Ali Jawad <ali.jawad@...> wrote:
>>
>> Hi
>> Thanks for your input, but as said this works at times yes and times
>> now so I am not sure it is a definite DB issue, the servers are in the
>> same LAN, and there are other modules that use the DB string that work
>> when launched before this one while this one does not work.
>> Regards
>>
>> On Sun, Jan 1, 2012 at 4:13 PM, Sammy Govind <govoiper@...> wrote:
>> > Hi,
>> > forget the whole list of errors and just resolve the DB connectivity
>> > between
>> > the Kamailio server and DB server first .
>> >
>> >> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> >> connect to MySQL server on 'xxxxxxxxx' (4)
>> >
>> >
>> > try connecting to the remote DB server 'xxxxxxxxx' from linux shell i.e
>> >
>> > # mysql -u<user> -p<passwd> -h 'xxxxxxxxx'
>> >
>> > Regards,
>> > Sammy
>> >
>> >
>> > On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad <ali.jawad@...>
>> > wrote:
>> >>
>> >> Hi All
>> >> I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is
>> >> that Kamailio at times fails to start up for no obvious reasons, I.e.
>> >> in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug
>> >> log "level 2 " shows the following :
>> >>
>> >> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> >> connect to MySQL server on 'xxxxxxxxx' (4)
>> >> 27(24762) ERROR: <core> [db.c:303]: could not add connection to the
>> >> pool27(24762) ERROR: group [group.c:211]: unable to connect to the
>> >> database
>> >> 27(24762) ERROR: <core> [sr_module.c:889]: init_mod_child(): Error
>> >> while initializing module group
>> >> (/usr/local/kamailio/lib/kamailio/modules_k/group.so)
>> >> 27(24762) ERROR: <core> [pt.c:481]: ERROR: fork_tcp_process():
>> >> init_child failed for process 27, pid 24762, "tcp receiver child=1"
>> >>
>> >> and then
>> >>
>> >>
>> >> 30(24765) : <core> [pass_fd.c:293]: ERROR: receive_fd: EOF on 45
>> >>  0(24735) ALERT: <core> [main.c:748]: child process 24762 exited
>> >> normally, status=255
>> >>  0(24735) INFO: <core> [main.c:766]: INFO: terminating due to SIGCHLD
>> >>
>> >> The problem happens on 4 different servers, I did try to compile more
>> >> than once, the servers are 32 Bit CentOS 5.6. The connection to the
>> >> database is monitored and there are no issues with connecting to the
>> >> DB "it works at times and times not for Kamailio so a user/pwd issue
>> >> is not likely to cause this, manual cnnect worked", config file errors
>> >> are not found.
>> >>
>> >> I did also check max no of connections on MySQL server which is set to
>> >> 500 on the server and only 100 cons are used. The group module uses
>> >> the same connection string as other modules  which is predefined  and
>> >> there are other modules that access the db before the group module and
>> >> those do not have a problem.
>> >>
>> >> Please advice.
>> >>
>> >> Regards
>> >>
>> >> _______________________________________________
>> >> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> >> sr-users@...
>> >> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>> >
>> >
>> >
>> > _______________________________________________
>> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> > sr-users@...
>> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>> >
>>
>>
>>
>> --
>> Ali Jawad
>> Information Systems Manager
>> Splendor Telecom (www.splendor.net)
>> Beirut, Lebanon
>> Phone: +9611373725/ext 116
>> FAX: +9611375554
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users@...
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users@...
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>

--

-- 
Ali Jawad
Information Systems Manager
Splendor Telecom (www.splendor.net)
Beirut, Lebanon
Phone: +9611373725/ext 116
FAX: +9611375554

Ali Jawad | 2 Jan 2012 12:24

Re: [SR-Users] Intermittent start up issue

Hi Daniel
Running on a LAN with no firewalls enabled, will try you suggestion
though first thing tomorrow morning, what are the implications of
running children=1 ?
Thanks

On Mon, Jan 2, 2012 at 2:03 PM, Daniel-Constantin Mierla
<miconda@...> wrote:
> Hello,
>
> check also for limits in the system/firewall, maybe there are limits on new
> connections per second. Try with children=1 and see if it happens again, if
> not, then it is something that blocks many new connections in short time.
>
> Cheers,
> Daniel
>
>
> On 1/2/12 5:31 AM, Sammy Govind wrote:
>
> Hi,
> Its all upto you then, that's an intermittent issue and information is not
> complete to trace the issue. Did you see the same Errors every time it fails
> !?
>
> --
> Regards
> Sammy
>
> On Sun, Jan 1, 2012 at 10:06 PM, Ali Jawad <ali.jawad@...> wrote:
>>
>> Hi
>> Thanks for your input, but as said this works at times yes and times
>> now so I am not sure it is a definite DB issue, the servers are in the
>> same LAN, and there are other modules that use the DB string that work
>> when launched before this one while this one does not work.
>> Regards
>>
>> On Sun, Jan 1, 2012 at 4:13 PM, Sammy Govind <govoiper@...> wrote:
>> > Hi,
>> > forget the whole list of errors and just resolve the DB connectivity
>> > between
>> > the Kamailio server and DB server first .
>> >
>> >> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> >> connect to MySQL server on 'xxxxxxxxx' (4)
>> >
>> >
>> > try connecting to the remote DB server 'xxxxxxxxx' from linux shell i.e
>> >
>> > # mysql -u<user> -p<passwd> -h 'xxxxxxxxx'
>> >
>> > Regards,
>> > Sammy
>> >
>> >
>> > On Fri, Dec 30, 2011 at 3:33 PM, Ali Jawad <ali.jawad@...>
>> > wrote:
>> >>
>> >> Hi All
>> >> I have tried the below with Kamailio 3.1.0 and 3.2.1. the problem is
>> >> that Kamailio at times fails to start up for no obvious reasons, I.e.
>> >> in 10 restarts Kamailio might fail to start 3,0 or 5 times. Te debug
>> >> log "level 2 " shows the following :
>> >>
>> >> 27(24762) ERROR: db_mysql [km_my_con.c:109]: driver error: Can't
>> >> connect to MySQL server on 'xxxxxxxxx' (4)
>> >> 27(24762) ERROR: <core> [db.c:303]: could not add connection to the
>> >> pool27(24762) ERROR: group [group.c:211]: unable to connect to the
>> >> database
>> >> 27(24762) ERROR: <core> [sr_module.c:889]: init_mod_child(): Error
>> >> while initializing module group
>> >> (/usr/local/kamailio/lib/kamailio/modules_k/group.so)
>> >> 27(24762) ERROR: <core> [pt.c:481]: ERROR: fork_tcp_process():
>> >> init_child failed for process 27, pid 24762, "tcp receiver child=1"
>> >>
>> >> and then
>> >>
>> >>
>> >> 30(24765) : <core> [pass_fd.c:293]: ERROR: receive_fd: EOF on 45
>> >>  0(24735) ALERT: <core> [main.c:748]: child process 24762 exited
>> >> normally, status=255
>> >>  0(24735) INFO: <core> [main.c:766]: INFO: terminating due to SIGCHLD
>> >>
>> >> The problem happens on 4 different servers, I did try to compile more
>> >> than once, the servers are 32 Bit CentOS 5.6. The connection to the
>> >> database is monitored and there are no issues with connecting to the
>> >> DB "it works at times and times not for Kamailio so a user/pwd issue
>> >> is not likely to cause this, manual cnnect worked", config file errors
>> >> are not found.
>> >>
>> >> I did also check max no of connections on MySQL server which is set to
>> >> 500 on the server and only 100 cons are used. The group module uses
>> >> the same connection string as other modules  which is predefined  and
>> >> there are other modules that access the db before the group module and
>> >> those do not have a problem.
>> >>
>> >> Please advice.
>> >>
>> >> Regards
>> >>
>> >> _______________________________________________
>> >> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> >> sr-users@...
>> >> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>> >
>> >
>> >
>> > _______________________________________________
>> > SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> > sr-users@...
>> > http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>> >
>>
>>
>>
>> --
>> Ali Jawad
>> Information Systems Manager
>> Splendor Telecom (www.splendor.net)
>> Beirut, Lebanon
>> Phone: +9611373725/ext 116
>> FAX: +9611375554
>>
>> _______________________________________________
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users@...
>> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users@...
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>
>
> --
> Daniel-Constantin Mierla -- http://www.asipto.com
> http://linkedin.com/in/miconda -- http://twitter.com/miconda
>
>
> _______________________________________________
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users@...
> http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
>

--

-- 
Ali Jawad
Information Systems Manager
Splendor Telecom (www.splendor.net)
Beirut, Lebanon
Phone: +9611373725/ext 116
FAX: +9611375554

Daniel-Constantin Mierla | 2 Jan 2012 12:26
Picon

Re: [SR-Users] usrloc, timer process and cache cleanup


On 12/23/11 8:43 PM, Andrew Pogrebennyk wrote:
> On 12/23/2011 08:18 PM, Stefan Sayer wrote:
>> shouldn't the db layer and driver be smart enough to do insert ... on
>> duplicate key update at least where it's supported?
> my fear is that such "first insert then update" policy will affect the
> performance. can create noise in the log on some db backends too..
this one is also a bit tricky to do, as it will require to change the 
database table definition depending on matching mode from 
registrar/usrloc. By RFC, the primary key per aor should be contact 
address for the location records. As we know that lot of phones are 
behind the nat, many users having same environment for home/work phones, 
kamailio can be configured to do the matching also with call id and path 
stack. Because of that, these checks are done inside the modules, there 
is no constraint at location table sql level.

Such approach as suggested in this discussion, will require to add 
proper unique keys depending on configuration from kamailio.cfg.

Cheers,
Daniel

--

-- 
Daniel-Constantin Mierla -- http://www.asipto.com
http://linkedin.com/in/miconda -- http://twitter.com/miconda


Gmane