Florian,<br><br>I had the same issue using Asterisk and Kamailio. Basically the problem is that Asterisk interprets the call as a Loop (in the worst case) or might continue resolving the call locally without taking care of the changes you made in Kamaili.<br>
<br>I solved my issue using 3XX (redirect) messages.<br>Example:<br>   sl_send_reply(&quot;301&quot;, &quot;Go Here&quot;);<br><br>Try that on teh first place, then you can continue using Asterisk&#39;s dialplan to change message details.<br>
<br>Cheers,<br>Uriel<br><br><div class="gmail_quote">On Tue, Dec 1, 2009 at 11:39 AM, Florian Meister <span dir="ltr">&lt;<a href="mailto:Florian.Meister@teleport.vol.at">Florian.Meister@teleport.vol.at</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br>
<br>
basically I&#39;m using this structure at the moment:<br>
<br>
SIP Users &lt;----&gt; Kamailio &lt;-----&gt; Asterisk &lt;-----&gt; PSTN<br>
<br>
I have to add a diversion-functionality at kamailio-level, so to simply rewrite $ru with something else defined in the database. That&#39;s working without problems. For billing issues, I also have to add a Remote-Party-ID header, set to the SIP user, which initiated the redirect in the database.<br>

<br>
Now to the problem:<br>
<br>
When a call is coming from PSTN, it&#39;s passing the asterisk server, then at kamailio level $ru is rewritten and sent back to asterisk (I&#39;m talking about a redirect to a number in PSTN here)<br>
<br>
What I&#39;ve seen from the logs is, that asterisk is seeing that it gets an invite back with the same call-id, and therefore it cancels the original invite and handles the whole call internally via the Local Channel. The Problem is, that in the invite sent from kamailio back to asterisk, I&#39;ve set a Remote-Party-ID header to tell asterisk to set the Callerid correctly for billing purposes. Now it seems that asterisk is _ignoring_ this header from the second invite.<br>

<br>
So is this an expected behavior ? If yes, how to do it correctly ?<br>
<br>
Below you can see the verbose output of asterisk. Since the call is handled at &quot;Local&quot; Channels the function to read sip headers does not work. The only message I get is &quot;thanks to SIP/tpsiptestproxyu01-00d0a0b8&quot;.<br>

<br>
    -- Called tpsiptestproxyu01/+435572949012<br>
    -- Now forwarding DAHDI/2-1 to &#39;Local/066480588134@from-internal&#39; (thanks to SIP/tpsiptestproxyu01-00d0a0b8)<br>
    -- Executing [066480588134@from-internal:1] NoOp(&quot;Local/066480588134@from-internal-d69e;2&quot;, &quot;435572501134&quot;) in new stack<br>
[Dec  1 15:14:50] WARNING[20506]: chan_sip.c:15797 func_header_read: This function can only be used on SIP channels.<br>
    -- Executing [066480588134@from-internal:2] NoOp(&quot;Local/066480588134@from-internal-d69e;2&quot;, &quot;&quot;) in new stack<br>
    -- Executing [066480588134@from-internal:3] Dial(&quot;Local/066480588134@from-internal-d69e;2&quot;, &quot;DAHDI/G0/066480588134&quot;) in new stack<br>
    -- Requested transfer capability: 0x00 - SPEECH<br>
    -- Called G0/066480588134<br>
    -- DAHDI/124-1 is proceeding passing it to Local/066480588134@from-internal-d69e;2<br>
    -- Local/066480588134@from-internal-d69e;1 is proceeding passing it to DAHDI/2-1<br>
<br>
In the SIP debug you can see that asterisk is cancelling the dialog with kamailio and doing it itself:<br>
<br>
13:49:30.589054 IP [--ASTERISK--].5060 &gt; [--KAMAILIO--].5060: SIP, length: 938<br>
E.......@..L..,L..,N........INVITE sip:+435572949012@[--KAMAILIO--] SIP/2.0<br>
Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport<br>
Max-Forwards: 70<br>
From: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;tag=as27658014<br>
To: &lt;sip:+435572949012@[--KAMAILIO--]&gt;<br>
Contact: &lt;sip:435572501134@[--ASTERISK--]&gt;<br>
Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]<br>
CSeq: 102 INVITE<br>
User-Agent: Asterisk PBX 1.6.1.5<br>
Remote-Party-ID: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;privacy=off;screen=yes<br>
Date: Tue, 01 Dec 2009 12:49:30 GMT<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO<br>
Supported: replaces, timer<br>
Content-Type: application/sdp<br>
Content-Length: 263<br>
<br>
v=0<br>
o=root 930830518 930830518 IN IP4 [--ASTERISK--]<br>
s=Asterisk PBX 1.6.1.5<br>
c=IN IP4 [--ASTERISK--]<br>
t=0 0<br>
m=audio 16924 RTP/AVP 8 101<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:101 telephone-event/8000<br>
a=fmtp:101 0-16<br>
a=silenceSupp:off - - - -<br>
a=ptime:20<br>
a=sendrecv<br>
<br>
13:49:30.591037 IP [--KAMAILIO--].5060 &gt; [--ASTERISK--].5060: SIP, length: 342<br>
E..r..@.@.[0..,N..,L.....^.aSIP/2.0 100 Trying<br>
Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060<br>
From: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;tag=as27658014<br>
To: &lt;sip:+435572949012@[--KAMAILIO--]&gt;<br>
Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]<br>
CSeq: 102 INVITE<br>
Server: OpenSER (1.3.2-notls (x86_64/linux))<br>
Content-Length: 0<br>
<br>
<br>
13:49:30.594345 IP [--KAMAILIO--].5060 &gt; [--ASTERISK--].5060: SIP, length: 1093<br>
E..a..@.@.XA..,N..,L.....M+LINVITE sip:066480588134@[--ASTERISK--]:5060;transport=udp SIP/2.0<br>
Record-Route: &lt;sip:[--KAMAILIO--];lr;ftag=as27658014&gt;<br>
Via: SIP/2.0/UDP [--KAMAILIO--];branch=z9hG4bK06.05390227.0<br>
Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060<br>
Max-Forwards: 69<br>
From: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;tag=as27658014<br>
To: &lt;sip:+435572949012@[--KAMAILIO--]&gt;<br>
Contact: &lt;sip:435572501134@[--ASTERISK--]&gt;<br>
Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]<br>
CSeq: 102 INVITE<br>
User-Agent: Asterisk PBX 1.6.1.5<br>
Date: Tue, 01 Dec 2009 12:49:30 GMT<br>
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO<br>
Supported: replaces, timer<br>
Content-Type: application/sdp<br>
Content-Length: 263<br>
Remote-Party-ID: &quot;435572949012&quot; &lt;<a href="mailto:sip%3A435572949012@tpseru01.tele.net">sip:435572949012@tpseru01.tele.net</a>&gt;;party=caller;privacy=none;screen=yes<br>
<br>
v=0<br>
o=root 930830518 930830518 IN IP4 [--ASTERISK--]<br>
s=Asterisk PBX 1.6.1.5<br>
c=IN IP4 [--ASTERISK--]<br>
t=0 0<br>
m=audio 16924 RTP/AVP 8 101<br>
a=rtpmap:8 PCMA/8000<br>
a=rtpmap:101 telephone-event/8000<br>
a=fmtp:101 0-16<br>
a=silenceSupp:off - - - -<br>
a=ptime:20<br>
a=sendrecv<br>
<br>
13:49:30.594605 IP [--ASTERISK--].5060 &gt; [--KAMAILIO--].5060: SIP, length: 460<br>
E.......@..)..,L..,N....... CANCEL sip:+435572949012@[--KAMAILIO--] SIP/2.0<br>
Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport<br>
Max-Forwards: 70<br>
From: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;tag=as27658014<br>
To: &lt;sip:+435572949012@[--KAMAILIO--]&gt;<br>
Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]<br>
CSeq: 102 CANCEL<br>
User-Agent: Asterisk PBX 1.6.1.5<br>
Remote-Party-ID: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;privacy=off;screen=yes<br>
Content-Length: 0<br>
<br>
<br>
13:49:30.596307 IP [--KAMAILIO--].5060 &gt; [--ASTERISK--].5060: SIP, length: 387<br>
E.....@.@.[...,N..,L.......KSIP/2.0 200 canceling<br>
Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060<br>
From: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;tag=as27658014<br>
To: &lt;sip:+435572949012@[--KAMAILIO--]&gt;;tag=45db18648893e7acabf725621374d382-4ddb<br>
Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]<br>
CSeq: 102 CANCEL<br>
Server: OpenSER (1.3.2-notls (x86_64/linux))<br>
Content-Length: 0<br>
<br>
<br>
13:49:30.596801 IP [--KAMAILIO--].5060 &gt; [--ASTERISK--].5060: SIP, length: 396<br>
E.....@.@.Z...,N..,L.......kSIP/2.0 487 Request Terminated<br>
Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport=5060<br>
From: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;tag=as27658014<br>
To: &lt;sip:+435572949012@[--KAMAILIO--]&gt;;tag=45db18648893e7acabf725621374d382-4ddb<br>
Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]<br>
CSeq: 102 INVITE<br>
Server: OpenSER (1.3.2-notls (x86_64/linux))<br>
Content-Length: 0<br>
<br>
<br>
13:49:30.596842 IP [--ASTERISK--].5060 &gt; [--KAMAILIO--].5060: SIP, length: 539<br>
E..7....@.....,L..,N.....#.oACK sip:+435572949012@[--KAMAILIO--] SIP/2.0<br>
Via: SIP/2.0/UDP [--ASTERISK--]:5060;branch=z9hG4bK5629d66b;rport<br>
Max-Forwards: 70<br>
From: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;tag=as27658014<br>
To: &lt;sip:+435572949012@[--KAMAILIO--]&gt;;tag=45db18648893e7acabf725621374d382-4ddb<br>
Contact: &lt;sip:435572501134@[--ASTERISK--]&gt;<br>
Call-ID: 4bbee84339a9e2d30850185317983625@[--ASTERISK--]<br>
CSeq: 102 ACK<br>
User-Agent: Asterisk PBX 1.6.1.5<br>
Remote-Party-ID: &quot;435572501134&quot; &lt;sip:435572501134@[--ASTERISK--]&gt;;privacy=off;screen=yes<br>
Content-Length: 0<br>
<br>
<br>
Thanks,<br>
<br>
Florian<br>
<br>
_______________________________________________<br>
Kamailio (OpenSER) - Users mailing list<br>
<a href="mailto:Users@lists.kamailio.org">Users@lists.kamailio.org</a><br>
<a href="http://lists.kamailio.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.kamailio.org/cgi-bin/mailman/listinfo/users</a><br>
<a href="http://lists.openser-project.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.openser-project.org/cgi-bin/mailman/listinfo/users</a><br>
</blockquote></div><br>