Asterisk <-> Kamailio with trunk

Hello all,

I’m trying to make solution of provide between web clients(JsSIP) and non-web clients(some softphones) via Kamailio and Asterisk I want use like media server. So, now I try make SIP trunk between them and I have an issue: when AST forwards INVITE back to Kamailio, the INVITE has invalid uri. In uri is missing begin of string: XXX@
here is some logs:
sip.conf:

[general]
allowguest=yes
maxexpirey=3600
defaultexpirey=3600
port=5060
bindaddr=0.0.0.0
nat=no
disallow=all
allow=alaw,ulaw
context=internal
allowoverlap=no
language=en
dtmfmode=info


[kamailio]
type=friend
context=internal
host=10.100.103.90  ; kamailio's IP
port=5060
transport=udp
trustrpid=yes
qualify=no
deny=0.0.0.0/0.0.0.0
permit=10.100.0.0/255.255.0.0  ; peers IP's

extensions.conf:

[internal]
exten => _XXX,1,Dial(SIP/kamailio) ; any call forward back to kamailio

SIP debug:

<--- SIP read from UDP:10.100.103.90:5060 --->
INVITE sip:201@10.100.103.90 SIP/2.0
Record-Route: <sip:10.100.103.90;lr=on;ftag=8548ba3f>
Via: SIP/2.0/UDP 10.100.103.90;branch=z9hG4bKab7b.f470a2a6ed0b2bda7e6f509687ce8da6.0
Via: SIP/2.0/UDP 10.100.102.236:45490;branch=z9hG4bK-d8754z-60669a05925b6435-1---d8754z-;rport=45490
Max-Forwards: 16
Contact: <sip:300@10.100.102.236:45490>
To: <sip:201@10.100.103.90>
From: "300"<sip:300@10.100.103.90>;tag=8548ba3f
Call-ID: ODE0YTg4OTdhNmU4YTFhZWVmNzc3NzczYmIzMTFjNjE
CSeq: 2 INVITE
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, NOTIFY, MESSAGE, SUBSCRIBE, INFO
Content-Type: application/sdp
Supported: replaces
User-Agent: X-Lite release 4.5.5 stamp 71236
Content-Length: 308

v=0
o=- 13043585822367121 1 IN IP4 10.100.102.236
s=X-Lite 4 release 4.5.5 stamp 71236
c=IN IP4 10.100.102.236
t=0 0
m=audio 54230 RTP/AVP 125 9 8 0 100 101
a=rtpmap:125 opus/48000/2
a=fmtp:125 useinbandfec=1
a=rtpmap:100 speex/16000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<------------->
--- (15 headers 12 lines) ---
Sending to 10.100.103.90:5060 (no NAT)
Sending to 10.100.103.90:5060 (no NAT)
Using INVITE request as basis request - ODE0YTg4OTdhNmU4YTFhZWVmNzc3NzczYmIzMTFjNjE
Found peer 'kamailio' for '300' from 10.100.103.90:5060
  == Using SIP RTP CoS mark 5
Found RTP audio format 125
Found RTP audio format 9
Found RTP audio format 8
Found RTP audio format 0
Found RTP audio format 100
Found RTP audio format 101
Found audio description format opus for ID 125
Found audio description format speex for ID 100
Found audio description format telephone-event for ID 101
Capabilities: us - (ulaw|alaw), peer - audio=(ulaw|alaw|speex16|g722|opus)/video=(nothing)/text=(nothing), combined - (ulaw|alaw)
Non-codec capabilities (dtmf): us - 0x0 (nothing), peer - 0x1 (telephone-event|), combined - 0x0 (nothing)
Peer audio RTP is at port 10.100.102.236:54230
Looking for 201 in internal (domain 10.100.103.90)
list_route: route/path hop: <sip:10.100.103.90;lr=on;ftag=8548ba3f>

<--- Transmitting (no NAT) to 10.100.103.90:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.100.103.90;branch=z9hG4bKab7b.f470a2a6ed0b2bda7e6f509687ce8da6.0;received=10.100.103.90
Via: SIP/2.0/UDP 10.100.102.236:45490;branch=z9hG4bK-d8754z-60669a05925b6435-1---d8754z-;rport=45490
Record-Route: <sip:10.100.103.90;lr=on;ftag=8548ba3f>
From: "300"<sip:300@10.100.103.90>;tag=8548ba3f
To: <sip:201@10.100.103.90>
Call-ID: ODE0YTg4OTdhNmU4YTFhZWVmNzc3NzczYmIzMTFjNjE
CSeq: 2 INVITE
Server: Asterisk PBX 12.1.0-rc3
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Contact: <sip:201@10.100.103.1:5060>
Content-Length: 0


<------------>
    -- Executing [201@internal:1] Dial("SIP/kamailio-00000024", "SIP/kamailio") in new stack
  == Using SIP RTP CoS mark 5
Audio is at 15288
Adding codec 100004 (alaw) to SDP
Adding codec 100003 (ulaw) to SDP
Reliably Transmitting (no NAT) to 10.100.103.90:5060:
INVITE sip:10.100.103.90:5060 SIP/2.0
Via: SIP/2.0/UDP 10.100.103.1:5060;branch=z9hG4bK5027f9b0
Max-Forwards: 70
From: "300" <sip:300@10.100.103.1>;tag=as4d141930
To: <sip:10.100.103.90:5060>
Contact: <sip:300@10.100.103.1:5060>
Call-ID: 454da3e737de861d429783677752714e@10.100.103.1:5060
CSeq: 102 INVITE
User-Agent: Asterisk PBX 12.1.0-rc3
Date: Sat, 03 May 2014 10:17:02 GMT
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 248

v=0
o=root 944365640 944365640 IN IP4 10.100.103.1
s=Asterisk PBX 12.1.0-rc3
c=IN IP4 10.100.103.1
t=0 0
m=audio 15288 RTP/AVP 8 0
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=silenceSupp:off - - - -
a=ptime:20
a=maxptime:150
a=sendrecv

---
    -- Called SIP/kamailio

<--- SIP read from UDP:10.100.103.90:5060 --->
SIP/2.0 484 Address Incomplete
Via: SIP/2.0/UDP 10.100.103.1:5060;branch=z9hG4bK5027f9b0
From: "300" <sip:300@10.100.103.1>;tag=as4d141930
To: <sip:10.100.103.90:5060>;tag=7433c587a7af879ae43e57fccdc9bf1b.93f7
Call-ID: 454da3e737de861d429783677752714e@10.100.103.1:5060
CSeq: 102 INVITE
Server: kamailio (4.1.2 (x86_64/linux))
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---
    -- Got SIP response 484 "Address Incomplete" back from 10.100.103.90:5060
Transmitting (no NAT) to 10.100.103.90:5060:
ACK sip:10.100.103.90:5060 SIP/2.0
Via: SIP/2.0/UDP 10.100.103.1:5060;branch=z9hG4bK5027f9b0
Max-Forwards: 70
From: "300" <sip:300@10.100.103.1>;tag=as4d141930
To: <sip:10.100.103.90:5060>;tag=7433c587a7af879ae43e57fccdc9bf1b.93f7
Contact: <sip:300@10.100.103.1:5060>
Call-ID: 454da3e737de861d429783677752714e@10.100.103.1:5060
CSeq: 102 ACK
User-Agent: Asterisk PBX 12.1.0-rc3
Content-Length: 0


---
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Auto fallthrough, channel 'SIP/kamailio-00000024' status is 'CHANUNAVAIL'

<--- Reliably Transmitting (no NAT) to 10.100.103.90:5060 --->
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/UDP 10.100.103.90;branch=z9hG4bKab7b.f470a2a6ed0b2bda7e6f509687ce8da6.0;received=10.100.103.90
Via: SIP/2.0/UDP 10.100.102.236:45490;branch=z9hG4bK-d8754z-60669a05925b6435-1---d8754z-;rport=45490
From: "300"<sip:300@10.100.103.90>;tag=8548ba3f
To: <sip:201@10.100.103.90>;tag=as4d5fcbce
Call-ID: ODE0YTg4OTdhNmU4YTFhZWVmNzc3NzczYmIzMTFjNjE
CSeq: 2 INVITE
Server: Asterisk PBX 12.1.0-rc3
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
X-Asterisk-HangupCause: Unallocated (unassigned) number
X-Asterisk-HangupCauseCode: 1
Content-Length: 0


<------------>
Really destroying SIP dialog '454da3e737de861d429783677752714e@10.100.103.1:5060' Method: INVITE

<--- SIP read from UDP:10.100.103.90:5060 --->
ACK sip:201@10.100.103.90 SIP/2.0
Via: SIP/2.0/UDP 10.100.103.90;branch=z9hG4bKab7b.f470a2a6ed0b2bda7e6f509687ce8da6.0
Max-Forwards: 16
To: <sip:201@10.100.103.90>;tag=as4d5fcbce
From: "300"<sip:300@10.100.103.90>;tag=8548ba3f
Call-ID: ODE0YTg4OTdhNmU4YTFhZWVmNzc3NzczYmIzMTFjNjE
CSeq: 2 ACK
Content-Length: 0

<------------->
--- (8 headers 0 lines) ---
Really destroying SIP dialog 'ODE0YTg4OTdhNmU4YTFhZWVmNzc3NzczYmIzMTFjNjE' Method: ACK

in kamailio log I can see:

May 3 12:17:02 debian /usr/local/sbin/kamailio[6313]: INFO: <script>: rU=<null>

Thank you for help!

Patrik

Please read the sample extensions.onf. This is is very basic dialplan stuff.

You want SIP/peer/digits or SIP/digits@peer. digits will probably be ${EXTEN}.

ok, thanks

now its working with
exten => _XXX,1,Dial(SIP/kamailio/${EXTEN})