Author Topic: Yate Redirect SIP 300 Multiple Choices  (Read 13820 times)

artur.baghdasaryan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Yate Redirect SIP 300 Multiple Choices
« on: September 15, 2017, 02:24:02 AM »
Dear Yate Team,

Please help to figure out why Yate cant redirect calls to destination which is in Contact header of SIP 300 Multiple Choices message.
I have enabled the pbxassist module and set diversion to yes.
Please could you advise where is the problem
Trace is below
20170915081051.612263 <sip:INFO> 'udp:0.0.0.0:5060' received 869 bytes SIP message from 1.1.1.1:5060 [0x1cfcef0]
------
INVITE sip:11111111@2.2.2.2;user=phone SIP/2.0
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK6a19fc4e
Max-Forwards: 70
From: "+2222222222" <sip:+2222222222@1.1.1.1>;tag=as6e0e860a
To: <sip:11111111@2.2.2.2;user=phone>
Contact: <sip:+2222222222@1.1.1.1:5060>
Call-ID: 40d6a8f200621e456cbf8c1431df234a@1.1.1.1:5060
CSeq: 102 INVITE
User-Agent: Test
Date: Fri, 15 Sep 2017 08:10:51 GMT
Session-Expires: 1800
Min-SE: 90
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces, timer
Content-Type: application/sdp
Content-Length: 238

v=0
o=root 497095320 497095320 IN IP4 1.1.1.1
s=Test
c=IN IP4 1.1.1.1
t=0 0
m=audio 14266 RTP/AVP 8 0 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=sendrecv
------
20170915081051.621309 <sip:INFO> 'udp:0.0.0.0:5060' sending code 100 0x7f8ef0002b90 to 1.1.1.1:5060 [0x1cfcef0]
------
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK6a19fc4e;received=1.1.1.1
From: "+2222222222" <sip:+2222222222@1.1.1.1>;tag=as6e0e860a
To: <sip:11111111@2.2.2.2;user=phone>
Call-ID: 40d6a8f200621e456cbf8c1431df234a@1.1.1.1:5060
CSeq: 102 INVITE
Server: Test
Content-Length: 0

------
20170915081051.621410 <sip/23:ALL> YateSIPConnection::YateSIPConnection(0x7f8ef0010ad0,0x7f8ef402c1e0) [0x7f8ef0012020]
20170915081051.621550 <sip/23:ALL> NAT address is '(null)' [0x7f8ef0012020]
20170915081051.621793 <sip/23:ALL> Set media: audio=alaw,mulaw [0x7f8ef0012020]
20170915081051.622182 <INFO> Could not classify call from '+2222222222', wasted 214 usec
20170915081051.622255 <cdrbuild:INFO> Got message 'call.route' for untracked id 'sip/23'
20170915081051.622328 <RegexRoute:ALL> Jumping to context 'from_internal' by rule #1 '${module}sip'
20170915081051.622664 <RegexRoute:ALL> Jumping to context 'aster_test' by rule #9 '${address}^1\.1\.1\.1:'
20170915081051.622723 <pbxassist:CALL> Created guest assistant for 'sip/23'
20170915081051.622855 <INFO> Routing call to '11111111' in context 'default' via 'sip/sip:2222222222@3.3.3.3' in 558 usec
20170915081051.622903 <sip/23:ALL> NAT address is '(null)' [0x7f8ef0012020]
20170915081051.623092 <sip/24:ALL> YateSIPConnection::YateSIPConnection(0x7f8ef00036d0,'sip:2222222222@3.3.3.3') [0x7f8edc00ee80]
20170915081051.623171 <sip:ALL> YateSIPEndPoint::buildParty(0x7f8edc014400,'(null)',0,(nil))
20170915081051.623239 <sip/24:ALL> NAT address is '(null)' [0x7f8edc00ee80]
20170915081051.623381 <sip/24:ALL> Set media: audio=alaw,mulaw,g729 [0x7f8edc00ee80]
20170915081051.627078 <sip:INFO> 'udp:0.0.0.0:5060' sending code 183 0x7f8edc010830 to 1.1.1.1:5060 [0x1cfcef0]
------
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK6a19fc4e;received=1.1.1.1
From: "+2222222222" <sip:+2222222222@1.1.1.1>;tag=as6e0e860a
To: <sip:11111111@2.2.2.2;user=phone>;tag=1459504950
Call-ID: 40d6a8f200621e456cbf8c1431df234a@1.1.1.1:5060
CSeq: 102 INVITE
Server: Test
Contact: <sip:11111111@2.2.2.2:5060>
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
Content-Length: 0

------
20170915081051.627200 <sip:INFO> 'udp:0.0.0.0:5060' sending 'INVITE sip:2222222222@3.3.3.3' 0x7f8edc014400 to 3.3.3.3:5060 [0x1cfcef0]
------
INVITE sip:2222222222@3.3.3.3 SIP/2.0
Max-Forwards: 69
Contact: <sip:2222222222@1.1.1.1:5060>
Via: SIP/2.0/UDP 2.2.2.2:5060;rport;branch=z9hG4bK962542606
From: <sip:2222222222@2.2.2.2>;tag=306964556
To: <sip:2222222222@3.3.3.3>
Call-ID: 564312445@2.2.2.2
CSeq: 44 INVITE
User-Agent: Test
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
Content-Type: application/sdp
Content-Length: 256

v=0
o=yate 1505463051 1505463051 IN IP4 2.2.2.2
s=SIP Call
c=IN IP4 2.2.2.2
t=0 0
m=audio 26938 RTP/AVP 8 0 18 101
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:101 telephone-event/8000
------
20170915081051.628027 <pbxassist:CALL> Created assistant for 'sip/24'
20170915081051.629268 <sip:INFO> 'udp:0.0.0.0:5060' received 278 bytes SIP message from 3.3.3.3:5060 [0x1cfcef0]
------
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 2.2.2.2:5060;rport;branch=z9hG4bK962542606
From: <sip:2222222222@2.2.2.2>;tag=306964556
To: <sip:2222222222@3.3.3.3>
Call-ID: 564312445@2.2.2.2
CSeq: 44 INVITE
Server: Invoice SIP-server
Content-Length: 0

------
20170915081051.639711 <sip:INFO> 'udp:0.0.0.0:5060' received 344 bytes SIP message from 3.3.3.3:5060 [0x1cfcef0]
------
SIP/2.0 300 Multiple choices
Via: SIP/2.0/UDP 2.2.2.2:5060;rport;branch=z9hG4bK962542606
From: <sip:2222222222@2.2.2.2>;tag=306964556
To: <sip:2222222222@3.3.3.3>
Call-ID: 564312445@2.2.2.2
CSeq: 44 INVITE
Contact: <sip:2222222222@188.115.195.177:5060>
                                               TG:  0
Server: Invoice SIP-server
Content-Length: 0

------
20170915081051.642651 <sip/24:ALL> YateSIPConnection::hangup() state=1 trans=0x7f8edc015c40 error='(null)' code=300 reason='Multiple choices' [0x7f8edc00ee80]
20170915081051.642724 <ALL> Cleaning up RTP 0x7f8edc00a950 [0x7f8edc00a7a0]
20170915081051.642781 <sip/23:ALL> YateSIPConnection::disconnected() 'Multiple choices' [0x7f8ef0012020]
20170915081051.642817 <sip/24:ALL> YateSIPConnection::~YateSIPConnection() [0x7f8edc00ee80]
20170915081051.642884 <sip:INFO> 'udp:0.0.0.0:5060' sending 'ACK sip:2222222222@3.3.3.3' 0x7f8ef4028160 to 3.3.3.3:5060 [0x1cfcef0]
------
ACK sip:2222222222@3.3.3.3 SIP/2.0
Via: SIP/2.0/UDP 2.2.2.2:5060;rport;branch=z9hG4bK962542606
From: <sip:2222222222@2.2.2.2>;tag=306964556
To: <sip:2222222222@3.3.3.3>
Call-ID: 564312445@2.2.2.2
CSeq: 44 ACK
Max-Forwards: 69
Contact: <sip:2222222222@1.1.1.1:5060>
User-Agent: Test
Content-Length: 0

------
20170915081051.643742 <INFO> Could not classify call from '2222222222', wasted 104 usec
20170915081051.643830 <INFO> Could not route call to '11111111' in context 'default', wasted 22 usec
20170915081051.643857 <pbxassist:MILD> Chan 'sip/23' operation failed: no route
20170915081051.643884 <sip/23:ALL> YateSIPConnection::hangup() state=0 trans=0x7f8ef402c1e0 error='noanswer' code=487 reason='Multiple choices' [0x7f8ef0012020]
20170915081051.643966 <sip/23:ALL> YateSIPConnection::~YateSIPConnection() [0x7f8ef0012020]
20170915081051.648052 <sip:INFO> 'udp:0.0.0.0:5060' sending code 487 0x7f8eec0175a0 to 1.1.1.1:5060 [0x1cfcef0]
------
SIP/2.0 487 Multiple choices
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK6a19fc4e;received=1.1.1.1
From: "+2222222222" <sip:+2222222222@1.1.1.1>;tag=as6e0e860a
To: <sip:11111111@2.2.2.2;user=phone>;tag=1459504950
Call-ID: 40d6a8f200621e456cbf8c1431df234a@1.1.1.1:5060
CSeq: 102 INVITE
Server: Test
Contact: <sip:11111111@2.2.2.2:5060>
Allow: ACK, INVITE, BYE, CANCEL, REGISTER, REFER, OPTIONS, INFO
Content-Length: 0

------
20170915081051.648564 <sip:INFO> 'udp:0.0.0.0:5060' received 418 bytes SIP message from 1.1.1.1:5060 [0x1cfcef0]
------
ACK sip:11111111@2.2.2.2:5060 SIP/2.0
Via: SIP/2.0/UDP 1.1.1.1:5060;branch=z9hG4bK6a19fc4e
Max-Forwards: 70
From: "+2222222222" <sip:+2222222222@1.1.1.1>;tag=as6e0e860a
To: <sip:11111111@2.2.2.2;user=phone>;tag=1459504950
Contact: <sip:+2222222222@1.1.1.1:5060>
Call-ID: 40d6a8f200621e456cbf8c1431df234a@1.1.1.1:5060
CSeq: 102 ACK
User-Agent: Test
Content-Length: 0

Monica Tepelus

  • Administrator
  • Full Member
  • *****
  • Posts: 198
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #1 on: September 18, 2017, 03:58:25 AM »
Hi,

Yate doesn't implement all SIP 300 variations.

Pbxassist was not thought to work with SIP 300 requests. If you wish to use the pbxassist functioality you should configure the phones to send the dmnfs to Yate and configure the combination of digits in yate's pbxassist module. You can't combine SIP redirects with Yate's pbxassist.


artur.baghdasaryan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #2 on: September 18, 2017, 06:20:16 AM »
Hi,

Dear Monica,

Thanks for your response.
Actually we do need to use extensions.We are using Yate to act as SBC for transit calls.
Please could You advise how to get some params from SIP message and use them as variables in different contexts as it is described above the call cant be routed as there is no route in default context.Like from 300 Multiple choices message can we extract the contact field,get the user part and host part separately and use them to initialize a new call.We want to set this params as variables in regexroute for to route calls according to contact field from 300 Multiple choices message.
Please can you share the regexroute example.
Great thanks in advance.

/Arthur

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #3 on: September 19, 2017, 01:02:19 AM »
You may handle yate internal messages.
Received contact may be found in 'sip_contact' parameter of:
chan.hangup message sent by outgoing sip call leg
chan.disconnected message sent by incoming call leg when disconnected from outgoing channel.

I would recommend to watch the chann.disconnected message: you may re-execute the incoming call leg

artur.baghdasaryan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #4 on: September 19, 2017, 01:25:50 AM »
Thanks Marian for response,

I do appreciate your advise,but the problem is how to re-execute the cha.disconnected message and grep the sip contact user and host part separately,
Please could you share the dialplan example.
Great thanks in advance.

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #5 on: September 19, 2017, 02:03:22 AM »
I don't know how choices are returned in contact header.

A call may be re-executed using chan.masquerade message.
Here is a javascript example of handling chan.disconnected:

function onChanDisc(msg)
{
    if (300 == msg.cause_sip) {
        var callto;
        // TODO:
        // - Logic to detect choices from message
        // - Logic to setup callto from choices (route)
        if (callto) {
            var m = new Message("chan.masquerade");
            m.message = "call.execute";
            m.id = msg.id;
            m.callto = callto;
            m.dispatch();
        }
   }
}

You may re-execute

artur.baghdasaryan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #6 on: September 19, 2017, 04:28:53 AM »
Thanks Marian for prompt responce.
Could you advise how to do the same with regexroute without using external module.
Like how to set sip_contact param in all messages and filter the host and user part from the Contact header.
If it is possible do via regex routing it will be more efficient for us to go that way.

Thanks in advance.

marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #7 on: September 19, 2017, 04:48:51 AM »
Javascript is not an external module. Yate has a javascript module. See http://docs.yate.ro/wiki/Javascript

A regexroute example:

[extra]
chan.disconnected=

[chan.disconnected]
${cause_sip}^300$={
  ; TODO:
  ; - Logic to detect choices from message
  ; - Logic to setup called target from choices (route)
  ; On success set 'CALLTO' parameter in handled message
  ${CALLTO}.=dispatch chan.masquerade;message=call.execute;id=${id};callto=${CALLTO}
}

You can find more at docs.yate.ro

http://docs.yate.ro/wiki/Regular_expressions
http://docs.yate.ro/wiki/How_to_convert_SIP_headers_into_SIP_parameters_names_in_messages
http://docs.yate.ro/wiki/Debugging_and,_or_Investigation_of_messages

artur.baghdasaryan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #8 on: September 20, 2017, 02:21:42 AM »
Thanks Marian,it works but in this case i cant get caller param from chan.disconected.
Is there any way to add this param in chan.disconnected message ? or some other way to get the real caller from the first Invite ?
Also he routeing is not stopped while call.execute message is initialized,like engine continues to further steps(call.preroute,call.route),how can we disable this behavior ?



marian

  • Hero Member
  • *****
  • Posts: 513
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #9 on: September 20, 2017, 03:29:56 AM »
You'll have to track the call to know its parameters.

A way to do it is to use a javascript routing script (see http://docs.yate.ro/wiki/How_to_do_routing_using_javascript)
The script will be attached to the incoming call leg. You may remember caller party in the script and handle redirect

You may also write a global script to track all call legs, remember their parameters and re-execute on disconnected.

I don't understand what do you mean by 'routing is not stopped'.
chan.disconnected is sent when the incoming call leg was detached: any internal routing process was terminated.
Please attach a log with message sniffer enabled.

artur.baghdasaryan

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Yate Redirect SIP 300 Multiple Choices
« Reply #10 on: September 20, 2017, 04:13:31 AM »
Thank You Marian,

I will proceed with javascript.
For routing part it is already ok.Some modules were not disabled.

Great thanks.