EXTEN with SIP port number

Hi there,

I have an context ‘sip-incoming’ for taking inbound calls and using the ${EXTEN} value determines which queue I want to route the call to. However, one of the providers seem to have the port number appended at the end; EG 01389555555:6080 so it isnt finding the label it needs.

I understand I can parse the value and manipulate to do what I need it to do but I was wondering how would I stop this happening at source? Do I need to speak to the provider?

Simplified dial plan below:

exten => _X!,1,VERBOSE(1,${EXTEN}) ; exten = XXXXXXXXXXX:8060 at this point
exten => _X!,n,Goto(label${EXTEN})
exten => _X!,n(label01389555555),Queue(MAIN1,ctT,1800,queueConnected)
exten => _X!,n(label01389666666),Queue(MAIN2,ctT,1800,queueConnected)
exten => _X!,n(label01389777777),Queue(MAIN3,ctT,1800,queueConnected)


Yes, you’d need to talk to the provider if they really are passing that information in the user portion of the SIP request URI.

I wonder if this is a misimplemented TEL: URI.

Thanks for the reply. I’ll go back to the provider on this one.

I went back to the client who had had a reply from the provider saying that this needs to be in this format as they are not using the default SIP port 5060. If they take the :8060 out of the string it wil default to the 5060 sip port.

However, I’m sure I’ve done work for clients before who have not used the default SIP port and never experienced this issue.

In fact the behavior is strange and it has nothing to do with which port they use.
I would use an AGI Script for situations like this. You can do it in a language you like, I like to use PHP. so like this

#!/usr/bin/php -q
$temp = explode(":",$argv[1]); // divdes the string at the : sign
$new_exten = $temp[0];
$stdout = fopen('php://stdout', 'w');
        fwrite($stdout, "SET VARIABLE NEWEXTEN ".$new_exten."\n"); // give the first part as dialplan var NEWEXTEN

Then in the dialplan you can do like

exten => _X!,1,AGI(yourscript.php,${EXTEN})
exten => _X!,n,Goto(label${NEWEXTEN})

Just as a quick, untested example.

The problem with the provider is that the port number is in the wrong place. Asterisk is behaving as if they had used sip:12345678:8060@domain, whereas, if they want to put the port number in the URI, it needs to be after the domain: sip:12345678@domain:8060.

It would help if you could provide the full content of the incoming INVITE request, as this would confirm that the problem is on their side.

My comment about TEL: URIs is that, because of extensive use, Asterisk now has limited support for them. For a TEL: URI, there must be no port number, simply: tel:12345678. It is up to their system to track domain and port by other means.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.