<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta http-equiv="Content-Type"
 content="text/html; charset=ISO-8859-1">
  <meta name="Generator" content="Microsoft Word 12 (filtered medium)">
  <style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.MsoListParagraph, li.MsoListParagraph, div.MsoListParagraph
        {mso-style-priority:34;
        margin-top:0cm;
        margin-right:0cm;
        margin-bottom:0cm;
        margin-left:36.0pt;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
span.EmailStyle18
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page Section1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.Section1
        {page:Section1;}
 /* List Definitions */
 @list l0
        {mso-list-id:1666781020;
        mso-list-type:hybrid;
        mso-list-template-ids:-1618968420 134807569 134807577 134807579 134807567 134807577 134807579 134807567 134807577 134807579;}
@list l0:level1
        {mso-level-text:"%1\)";
        mso-level-tab-stop:none;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level2
        {mso-level-tab-stop:72.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level3
        {mso-level-tab-stop:108.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level4
        {mso-level-tab-stop:144.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level5
        {mso-level-tab-stop:180.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level6
        {mso-level-tab-stop:216.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level7
        {mso-level-tab-stop:252.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level8
        {mso-level-tab-stop:288.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
@list l0:level9
        {mso-level-tab-stop:324.0pt;
        mso-level-number-position:left;
        text-indent:-18.0pt;}
ol
        {margin-bottom:0cm;}
ul
        {margin-bottom:0cm;}
-->
  </style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="#ffffff" text="#000000">
Hello,<o:p></o:p>
<div class="Section1">
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Currently I have big troubles in the combination
of PRESENCE
/ PRESENCE_XML (/ PUA / PUA_USRLOC) &nbsp;with POSTGRESQL database. During
last
days I&#8217;ve analyzed the output of Kamailio 3.0.2 and PostgreSQL (8.3)
database, running on Debian Lenny OS. Following items were found:<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph" style="text-indent: -18pt;"><!--[if !supportLists]--><span
 style="">1)<span
 style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><!--[endif]-->The default settings of 4 PGSQL tables
after initializing
the database with &#8220;kamdbctl init&#8221; are not useful; the tables
&#8220;PRESENTITY&#8221;, &#8220;PUA&#8221;, &#8220;ACC&#8221; and
&#8220;MISSED_CALLS&#8221; have wrong settings for &#8220;Not NULL&#8221;
characteristics of some columns. In detail following columns had to be
adapted manually
in the database:<o:p></o:p></p>
<p class="MsoListParagraph">&#8220;acc&#8221; and &#8220;missed_calls&#8221;
table : column &#8220;id&#8221; must allow &#8220;NULL&#8221; (remove
&#8220;Not Null&#8221; setting)<o:p></o:p></p>
<p class="MsoListParagraph">&#8220;presentity&#8221; table: the column
&#8220;sender&#8221; must allow &#8220;NULL&#8221; (remove &#8220;Not
Null&#8221; setting)<o:p></o:p></p>
<p class="MsoListParagraph">&#8220;pua&#8221; table: the columns
&#8220;extra_headers&#8221;, &#8220;version&#8221;,
&#8220;remote_contact&#8221;, &#8220;contact&#8221; and
&#8220;desired_expires&#8221; must allow &#8220;NULL&#8221; (remove &#8220;Not
Null&#8221; setting)<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph">E.g.<o:p></o:p></p>
<p class="MsoListParagraph">883:4451: 0(7123) ERROR: db_postgres
[km_dbase.c:428]: driver error: PGRES_FATAL_ERROR, ERROR:&nbsp; null value
in
column "sender" violates not-null constraint<o:p></o:p></p>
<p class="MsoListParagraph">1008:5057: 1(7134) ERROR: db_postgres
[km_dbase.c:428]: driver error: PGRES_FATAL_ERROR, ERROR:&nbsp; null value
in
column "extra_headers" violates not-null constraint<o:p></o:p></p>
<p class="MsoListParagraph">1025:5078: 1(7134) ERROR: db_postgres
[km_dbase.c:428]: driver error: PGRES_FATAL_ERROR, ERROR:&nbsp; null value
in
column "version" violates not-null constraint<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph">I recommend adapting the script
&#8220;utils/kamctl/postgres/presence-create.sql&#8221;!<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph" style="text-indent: -18pt;"><!--[if !supportLists]--><span
 style="">2)<span
 style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><!--[endif]-->I do not know if this has a direct
influence on the
problems I have with presence, but the column &#8220;sender&#8221; in the table
&#8220;presentity&#8221; seems to be used only &#8220;half&#8221;. When the
pua_usrloc module is inserting an entry into the table it does NOT
insert a
value for the column &#8220;sender&#8221;. However, when a query is sent for
selecting information from this table, the column &#8220;sender&#8221; is
explicitly requested&#8230;&#8230;<o:p></o:p></p>
<p class="MsoListParagraph">e.g.<o:p></o:p></p>
<p class="MsoListParagraph">INSERTION (no &#8220;sender&#8221; value is inserted):<o:p></o:p></p>
<p class="MsoListParagraph">Jun 18 20:15:01 TestKam
/usr/sbin/kamailio[3151]:
DEBUG: db_postgres [km_dbase.c:149]: 0x826ba68 PQsendQuery(insert into
presentity (domain,username,event,etag,expires,body,received_time )
values
('192.168.150.11','116333','presence','a.1276884785.3151.1.0',1276885262,'&lt;?xml
version="1.0"?&gt;\\012&lt;presence
xmlns="urn:ietf:params:xml:ns:pidf"
xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model"
xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid"
xmlns:c="urn:ietf:params:xml:ns:pidf:cipid"
entity=<a class="moz-txt-link-rfc2396E" href="mailto:116333@192.168.150.11">"116333@192.168.150.11"</a>&gt;\\012&nbsp; &lt;tuple
id="0x828d7d8"&gt;\\012&nbsp;&nbsp;&nbsp;
&lt;status&gt;\\012&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&lt;basic&gt;open&lt;/basic&gt;\\012&nbsp;&nbsp;&nbsp;
&lt;/status&gt;\\012&nbsp; &lt;/tuple&gt;<a moz-do-not-send="true"
 href="file:///%5C%5C012%3c%5Cpresence%3e%5C012%27,1276884901%29">\\012&lt;/presence&gt;\\012',1276884901)</a>)<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph">SELECTION (a &#8220;sender&#8221; value is explicitly
queried):<o:p></o:p></p>
<p class="MsoListParagraph">Jun 18 20:15:08 TestKam
/usr/sbin/kamailio[3151]:
DEBUG: db_postgres [km_dbase.c:149]: 0x826ba68 PQsendQuery(select
body,sender
from presentity where domain='192.168.150.11' AND username='116333' AND
event='presence' AND etag='a.1276884785.3151.1.0')<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph">What does the column &#8220;sender&#8221; represent?
In the presence description on the Kamailio homepage (version 1.5) this
column
still is not included.<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph" style="text-indent: -18pt;"><!--[if !supportLists]--><span
 style="">3)<span
 style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><!--[endif]-->The next problem I have is, that the
PIDF-body, which
is stored in the PGSQL database, seems to cause an error in the
presence_xml
module and therefore no body is attached to the NOTIFY message. The
NOTIFY
message contains a SIP header &#8220;Content-Type: application/pidf+xml&#8221;,
but no PIDF-body is sent in this message. As result of this SIP request
the SIP
user agent (= subscriber) is a little bit confused&#8230;.. I think that
problem in general has something to do with the &#8220;error&#8221; described
in the new task from Friday June 18<sup>th</sup> (<a
 moz-do-not-send="true"
 href="http://lists.sip-router.org/pipermail/sr-dev/2010-June/007865.html">http://lists.sip-router.org/pipermail/sr-dev/2010-June/007865.html</a>).
First
I wondered, why this problem only occurred in case that a (subscribed)
user agent de-registers from Kamailio registrar server. But I guess the
NOTIFY
message after registration of the user agent is created without
dependency on a
PGSQL query (= generated with information from memory). Another
behaviour of
the server was, that (after emptying all related tables) the first
registration
/ de-registration flow didn&#8217;t cause any error (both NOTIFY messages
were
readable and contained a PIDF-body); only beginning at the second flow
the body
could not be parsed. This was tested with SIPp sending
register/de-register
messages in a period of 3 seconds.<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph">The Kamailio error message looks like:<o:p></o:p></p>
<p class="MsoListParagraph">Jun 18 13:08:16 TestKam
/usr/sbin/kamailio[3167]:
ERROR: presence_xml [notify_body.c:515]: while parsing xml body message<o:p></o:p></p>
<p class="MsoListParagraph">Jun 18 13:08:16 TestKam
/usr/sbin/kamailio[3167]:
ERROR: presence_xml [notify_body.c:84]: while aggregating body<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph" style="text-indent: -18pt;"><!--[if !supportLists]--><span
 style="">4)<span
 style="font-family: &quot;Times New Roman&quot;; font-style: normal; font-variant: normal; font-weight: normal; font-size: 7pt; line-height: normal; font-size-adjust: none; font-stretch: normal; -x-system-font: none;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span></span><!--[endif]-->I don&#8217;t know if the parser might be
influenced by
a WARNING that is generated by the postgresql daemon whenever an entry
into the
presentity table is done (including XML body). From Kamailio log output
I saw
that the special characters &#8220;#011&#8221; and &#8220;#012&#8221; are
included in the XML body. I guess that is the octal notation of \t
(horizontal
tab) and \n (newline). <o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph">However, postgresql generates an error
message that
looks like following:<o:p></o:p></p>
<p class="MsoListParagraph"><em><span
 style="font-family: &quot;Calibri&quot;,&quot;sans-serif&quot;;">WARNING:&nbsp;
nonstandard use of \\ in a string literal at character 162<o:p></o:p></span></em></p>
<p class="MsoListParagraph">HINT:&nbsp; Use the escape string syntax for
backslashes, e.g., E'\\'.<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoListParagraph">Maybe this has some influence on the parser
problem,
too. Because in this version of Postgresql the parameter
&#8220;standard_conforming_strings&#8221;
is implicitly on &#8211; just for previous versions it could be set to off.
That
means, that any backslash symbol (\) is interpreted as standard
character (no
escape). Therefore the queried result of the database does no longer
include \n
and \t.<o:p></o:p></p>
<p class="MsoListParagraph"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">As interim &#8220;solution&#8221; of this problem I changed
to the MySQL database instead of PostgreSQL. The &#8220;Not NULL&#8221;
violation is the same, but MySQL seems to ignore this violation. Also
the XML
body is stored in MySQL &#8220;as wished&#8221; &#8211; that means: all special
characters are stored and the queried body still contains it. <o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">The modules &#8220;pua&#8221; and &#8220;pua_usrloc&#8221;
are used for testing purposes only, because the user agents send
publish
messages themselves. Therefore it is not necessary using this module.
But for
some regression tests I used a command line base user agent that does
not
support publish messages. But the problem is the same &#8211; independent
from
the user agent and where the publish messages is generated.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">&nbsp;Additionally I have attached a ZIP file that
contains traces
of the SIP traffic to/from Kamailio and Kamailio internally (Publish)
and two
excerpts of Kamailio syslog. The syslog excerpts are from two register
/
de-register sequences, where the first sequence was okay and the second
one generated
the parsing error. I haven&#8217;t found any essential difference that would
clarify the different behaviour of Kamailio.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Please give me some comments to these problems ;-)
I know,
PostgreSQL is only &#8220;second quality&#8221; for Kamailio, but it has some
advantages against MySQL, too.<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Thanks in advance and regards,<o:p></o:p></p>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p class="MsoNormal">Klaus Feichtinger<o:p></o:p></p>
</div>
</body>
</html>