<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body text="#000000" bgcolor="#ffffff">
    <br>
    <br>
    On 12/28/10 11:28 AM, Daniel-Constantin Mierla wrote:
    <blockquote cite="mid:4D19BBCC.3050101@gmail.com" type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      Hello,<br>
      <br>
      looking in the sources, at least for 3.x, ldap module does not
      connect to server from timer process, the one that executes
      failure route for local timeout.<br>
      <br>
      I will fix it.<br>
    </blockquote>
    Seemed to be a feature -- ldap module had it this way from its
    beginning. I committed the update that should create connection to
    Ldap server from timer processes, so the functions should work now
    in failure route in all cases.<br>
    <br>
    The patch was committed on svn branch 1.5 as well, you need to fetch
    the latest version from there and reinstall in order to try it.<br>
    <br>
    Let me know if all works fine now.<br>
    <br>
    Daniel<br>
    <br>
    <blockquote cite="mid:4D19BBCC.3050101@gmail.com" type="cite"> <br>
      Cheers,<br>
      Daniel<br>
      <br>
      On 12/27/10 5:03 PM, Pan B. Christensen wrote:
      <blockquote cite="mid:27E04FBE07B34E7D907C08D66DAF13E6@rtPC"
        type="cite">
        <meta content="text/html; charset=ISO-8859-1"
          http-equiv="Content-Type">
        <meta name="GENERATOR" content="MSHTML 8.00.6001.18999">
        <style></style>
        <div><font face="Arial" size="2">Hello,</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">We are using kamailio 1.5 and
            we have the following problem with ldap_search:</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">A call comes in. If it is to a
            VOIP user, it will be routed to kamailio, and eventually go
            to the ldap lookup route: route[10] to look up the user.<br>
            This is always successful (LDAP can connect).<br>
            It will then look up user preferences (call forwarding etc.)
            from SQL in route[12] and route based on this result in
            route[13].<br>
            If the result is "CFU (call forward unconditional) = on",
            the URI is changed and route[10] (LDAP lookup) is called
            again.<br>
            This is always successful (LDAP can connect).<br>
            If the result is "CFB (call forward busy) = on" and the user
            is busy, the URI is changed and route[10] (LDAP lookup) is
            called again.<br>
            This is also always successful (LDAP can connect).<br>
            If the result is "CFNR (call forward no reply) = on", the
            timeout is changed and the call is delivered to the phone
            through route[14] (location) and route[15] (relay).<br>
            If the user does not answer, the URI is changed in
            failure_route[1] and route[10] is called.<br>
            For some unknown reason, ldap_search always fails in this
            scenario with the messages: "ldap_session not found",
            "couldn't get ldap session" and then "no LDAP entry found".<br>
            Why?<br>
            And why does this result in the -1 return code and not the
            -2 return code for ldap_search?</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">The only differences I can
            think of is that the unsuccessful scenario comes from
            FAILURE_ROUTE instead of REQUEST_ROUTE, and that longer time
            has passed since the original invite.</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">Here's a sample log:<br>
            NOTE the three ERROR lines, the INFO line and the ROUTE 10
            line.</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">Dec 27 13:31:55 [3373]: INVITE
            received from sip:&lt;CALLER&gt;@&lt;SBC_IP&gt; &lt;source
            IP: &lt;SBC_IP&gt;&gt; to sip:&lt;CALLEE&gt;@&lt;KAM_IP&gt;:<br>
            Dec 27 13:31:55 [3373]: ERROR:<a moz-do-not-send="true"
              class="moz-txt-link-freetext" href="ldap:ldap_reconnect:">ldap:ldap_reconnect:</a>
            [ldapprod]: LDAP reconnect successful<br>
            Dec 27 13:31:55 [3373]: ROUTE 10: LDAP returned: UID =
            &lt;UID&gt;, voipSipPrimaryUri = &lt;PRIMARY_URI&gt;,
            voipExtensionUri = sip:&lt;CALLEE&gt;@&lt;DOMAIN&gt;<br>
            Dec 27 13:31:55 [3373]: ROUTE 12: Effective user properties
            for UID &lt;UID&gt;: CFU: off &lt;FORWARDTO&gt;, CFB: off
            &lt;FORWARDTO&gt;, CFNR: on:25 &lt;FORWARDTO&gt;, CFNC: off
            &lt;FORWARDTO&gt;, VM: &lt;CALLEE&gt;, busy_level: 1,
            DBrows: 1<br>
            Dec 27 13:31:55 [3373]:&nbsp;-------------------- Calling
            sip:&lt;CALLEE&gt;@&lt;DOMAIN&gt; for 25 seconds.
            --------------------<br>
            Dec 27 13:31:55 [3373]: ROUTE 15: Sending 105 INVITE from
            sip:&lt;CALLER&gt;@&lt;SBC_IP&gt; to
            sip:&lt;CALLEE&gt;@&lt;CALLEE_IP&gt; (via
            &lt;&lt;null&gt;&gt;)<br>
            Dec 27 13:31:55 [3383]: Response 100 Trying to Cseq 102
            INVITE received from
            &lt;PROTO&gt;:&lt;CALLEE_IP&gt;:&lt;PORT&gt;<br>
            Dec 27 13:31:55 [3385]: Response 180 Ringing to Cseq 102
            INVITE received from
            &lt;PROTO&gt;:&lt;CALLEE_IP&gt;:&lt;PORT&gt;</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">Dec 27 13:32:20 [3388]:
            FAILURE_ROUTE 1: Timeout for: 104 INVITE from &lt;CALLER&gt;
            -&gt; &lt;CALLEE&gt;<br>
            Dec 27 13:32:20 [3388]: -------------------- Forwarding on
            no reply to &lt;FORWARDTO&gt; --------------------<br>
            Dec 27 13:32:20 [3388]: ERROR:<a moz-do-not-send="true"
              class="moz-txt-link-freetext"
              href="ldap:get_connected_ldap_session:">ldap:get_connected_ldap_session:</a>
            [ldapprod]: ldap_session not found<br>
            Dec 27 13:32:20 [3388]: ERROR:<a moz-do-not-send="true"
              class="moz-txt-link-freetext" href="ldap:lds_search:">ldap:lds_search:</a>
            [ldapprod]: couldn't get ldap session<br>
            Dec 27 13:32:20 [3388]: INFO:<a moz-do-not-send="true"
              class="moz-txt-link-freetext"
              href="ldap:ldap_search_impl:">ldap:ldap_search_impl:</a>
            no LDAP entry found<br>
            Dec 27 13:32:20 [3388]: ROUTE 11: Number lookup results for
            &lt;FORWARDTO&gt;: Node: VOIP.<br>
            Dec 27 13:32:20 [3388]: CONFIG ERROR: VOIP number not found
            in LDAP. Hanging up.<br>
            Dec 27 13:32:20 [3373]: Response 487 Request Cancelled to
            Cseq 102 INVITE received from
            &lt;PROTO&gt;:&lt;CALLEE_IP&gt;:&lt;PORT&gt;</font></div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">Here's the ldap config file:</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">[ldapprod]<br>
            ldap_server_url = "<a moz-do-not-send="true"
              href="ldap://ldap.%3CDOMAIN">ldap://ldap.&lt;DOMAIN</a>&gt;"<br>
            ldap_network_timeout = 500<br>
            ldap_client_bind_timeout = 500</font></div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">kamailio config snippets (in
            case you need them):</font></div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2"># LDAP lookup for UID and
            primary URI<br>
            route[10] {<br>
            ...<br>
            &nbsp;&nbsp;ldap_search("<a moz-do-not-send="true"
href="ldap://ldapprod/%3CDN%3E?uid,voipSipPrimaryUri,voipExtensionUri?one?%28&amp;%28objectClass=voipAddress%29%28%7C%28voipSipUri=sip:$rU@uio.no%29%28%7C%28voipSipUri=$var%28uri%29%29%28voipSipUri=$var%28e164uri">ldap://ldapprod/&lt;DN&gt;?uid,voipSipPrimaryUri,voipExtensionUri?one?(&amp;(objectClass=voipAddress)(|(voipSipUri=sip:$rU@uio.no)(|(voipSipUri=$var(uri))(voipSipUri=$var(e164uri</a>)))))");<br>
            &nbsp;&nbsp;if ($retcode &lt; 1) {<br>
            &nbsp;&nbsp;&nbsp;switch ($retcode) {<br>
            &nbsp;&nbsp;&nbsp;case -1:<br>
            &nbsp;&nbsp;&nbsp;&nbsp;# no LDAP entry found<br>
            &nbsp;&nbsp;&nbsp;&nbsp;route(11);<br>
            &nbsp;&nbsp;&nbsp;&nbsp;return(1);<br>
            &nbsp;&nbsp;&nbsp;case -2:<br>
            &nbsp;&nbsp;&nbsp;&nbsp;# internal error<br>
            &nbsp;&nbsp;&nbsp;&nbsp;sl_send_reply("500", "Internal server error");<br>
            &nbsp;&nbsp;&nbsp;&nbsp;exit;<br>
            &nbsp;&nbsp;&nbsp;}<br>
            &nbsp;&nbsp;}<br>
            &nbsp;&nbsp;ldap_result("uid/$avp(s:uid)");<br>
            &nbsp;&nbsp;$avp(s:exten) = null;<br>
            &nbsp;&nbsp;if (!ldap_result("voipExtensionUri/$avp(s:exten)")) {<br>
            &nbsp;&nbsp;&nbsp;xlog("L_INFO", "voipExtensionUri not found.\n");<br>
            &nbsp;&nbsp;}<br>
            &nbsp;&nbsp;if (!ldap_result("voipSipPrimaryUri/$avp(s:p-uri)")) {<br>
            &nbsp;&nbsp;&nbsp;xlog("L_WARN", "voipSipPrimaryUri not found.\n");<br>
            &nbsp;&nbsp;&nbsp;#exit here?<br>
            &nbsp;&nbsp;}<br>
            &nbsp;&nbsp;if (isflagset(1)) {<br>
            &nbsp;&nbsp;&nbsp;xlog("L_INFO", "ROUTE 10: LDAP returned: UID =
            $avp(s:uid), voipSipPrimaryUri = $avp(s:p-uri),
            voipExtensionUri = $avp(s:exten)\n");<br>
            &nbsp;&nbsp;}<br>
            &nbsp;&nbsp;if $avp(s:exten) != null {<br>
            &nbsp;&nbsp;&nbsp;$ru=$avp(s:exten);<br>
            &nbsp;&nbsp;} else {<br>
            &nbsp;&nbsp;&nbsp;$ru=$avp(s:p-uri);<br>
            &nbsp;&nbsp;}<br>
            &nbsp;&nbsp;route(12);<br>
            &nbsp;}<br>
            }</font></div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2"># Number lookup. Non-VoIP URI's
            go here.<br>
            route[11] {<br>
            ...<br>
            }</font></div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2"># Database lookup for call
            forwarding.<br>
            route[12] {<br>
            ...<br>
            }</font></div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2"># Call forwarding logic<br>
            route[13] {<br>
            &nbsp;if (is_method("INVITE")) {<br>
            &nbsp;&nbsp;$avp(s:uio_timer_avp) = "300";<br>
            &nbsp;&nbsp;if ($avp(s:cfu_status) == "on") {<br>
            &nbsp;&nbsp;&nbsp;# Forward immediately<br>
            &nbsp;&nbsp;&nbsp;xlog("L_INFO", "-------------------- $rU forwarded
            unconditionally to $avp(s:cfu_number).
            --------------------\n");<br>
            &nbsp;&nbsp;&nbsp;$rU = $avp(s:cfu_number);<br>
            &nbsp;&nbsp;&nbsp;route(10);<br>
            &nbsp;&nbsp;}<br>
            ...<br>
            &nbsp;&nbsp;&nbsp;if ( $var(dlg_busy) &gt;= $avp(s:busy_level) ) {<br>
            &nbsp;&nbsp;&nbsp;&nbsp;if ($avp(s:cfb_status) == "on") {<br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;xlog("L_INFO", "-------------------- $rU has
            $var(dlg_busy) active calls. Treshold $avp(s:busy_level).
            Forwarding on busy to $avp(s:cfb_number)
            --------------------\n");<br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;$rU = $avp(s:cfb_number);<br>
            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;route(10);<br>
            &nbsp;&nbsp;&nbsp;&nbsp;}<br>
            ...<br>
            &nbsp;&nbsp;&nbsp;else if ($avp(s:cfnr_status) == "on") {<br>
            &nbsp;&nbsp;&nbsp;&nbsp;# Forward to phone with timeout then to
            $avp(s:cfnr_number).<br>
            &nbsp;&nbsp;&nbsp;&nbsp;# t_set_fr($avp(s:cfnr_timeout) + "000"); # Recommended
            method in 3.1. Function does not exist in 1.5. Using old
            method (avp).<br>
            &nbsp;&nbsp;&nbsp;&nbsp;$avp(s:uio_timer_avp) = $avp(s:cfnr_timeout);<br>
            &nbsp;&nbsp;&nbsp;&nbsp;xlog("L_INFO", "-------------------- Calling $ru for
            $avp(s:uio_timer_avp) seconds. --------------------\n");<br>
            &nbsp;&nbsp;&nbsp;&nbsp;route(14);<br>
            &nbsp;&nbsp;&nbsp;}<br>
            ...<br>
            }</font></div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">failure_route[1] {<br>
            ...<br>
            &nbsp;&nbsp;if $avp(s:cfnr_status) == "on" {<br>
            &nbsp;&nbsp;&nbsp;if (isflagset(1)) {<br>
            &nbsp;&nbsp;&nbsp;&nbsp;xlog("L_INFO", "FAILURE_ROUTE 1: Timeout for: $mi $rm
            from $fU -&gt; $rU\n");<br>
            &nbsp;&nbsp;&nbsp;}<br>
            &nbsp;&nbsp;&nbsp;revert_uri();<br>
            &nbsp;&nbsp;&nbsp;$rU = $avp(s:cfnr_number);<br>
            &nbsp;&nbsp;&nbsp;xlog("L_INFO", "-------------------- Forwarding on no
            reply to $rU --------------------\n");<br>
            &nbsp;&nbsp;&nbsp;route(10);<br>
            &nbsp;&nbsp;}<br>
            ...<br>
            }</font></div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div>&nbsp;</div>
        <div><font face="Arial" size="2">With kind regards,<br>
            Pan</font></div>
        <pre wrap=""><fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a moz-do-not-send="true" class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</a>
<a moz-do-not-send="true" 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>
</pre>
      </blockquote>
      <br>
      <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Jan 24-26, 2011, Irvine, CA, USA
<a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
      <pre wrap="">
<fieldset class="mimeAttachmentHeader"></fieldset>
_______________________________________________
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:sr-users@lists.sip-router.org">sr-users@lists.sip-router.org</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>
</pre>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Daniel-Constantin Mierla
Kamailio (OpenSER) Advanced Training
Jan 24-26, 2011, Irvine, CA, USA
<a class="moz-txt-link-freetext" href="http://www.asipto.com">http://www.asipto.com</a></pre>
  </body>
</html>