Summary:ASTERISK-15241: Asterisk 1.6.1 won't "answer" the phone when using a callcentric sip trunk
Reporter:Russell Cattelan (cattelan)Labels:
Date Opened:2009-11-30 11:16:32.000-0600Date Closed:2011-12-15 09:27:10.000-0600
Versions:Frequency of
is duplicated byASTERISK-18076 Asterisk 1.6.1 won't "answer" the phone when using a callcentric sip trunk
Environment:Attachments:( 0) asterisk-not-1.6
( 1) asterisk-ok-1.4
( 2) invite1.4
( 3) invite1.6_too
( 4) pbx_debug
( 5) pbx_debug_1.4
( 6) reload
( 7) reload1.4
Description:I have been trying for a while to upgrade my system from a 1.4 based asterisk to a 1.6 asterisk, but have never been able to get it to function correctly with my sip provider (calcentric)

I finally sat down and did some comparisons of the sip debug info and I think I have found an issue.

callcentric wants to use port 5080 vs the standard 5060 port.
It appears that 1.4 is correctly sending the sip answer message via port 5080 but 1.6 does not -- it is trying to use port 5060.

Here is the relevant sip debug messages.

asterisk 1.4.22

   -- Executing [s@ivr-2:7] Answer("SIP/", "") in new stack
Audio is at port 12644
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
<--- Reliably Transmitting (no NAT) to --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP;branch=z9hG4bK-26fd0d9fbdc6e35702ab0c2b568e095a;received=
From: "Russell Cattelan" <sip:16128053144@>;tag=3468510726-41122
To: <sip:16514820379@ss.callcentric.com>;tag=as700a9f61
Call-ID: 13715408-3468510726-41097@msw1.telengy.net
User-Agent: Asterisk PBX
Supported: replaces
Contact: <sip:17772080931@>
Content-Type: application/sdp
Content-Length: 258

o=root 21108 21108 IN IP4
c=IN IP4
t=0 0
m=audio 12644 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -

Asterisk 1.6.1

   -- SIP/203-a8007498 answered SIP/
Audio is at port 15980
Adding codec 0x4 (ulaw) to SDP
Adding codec 0x8 (alaw) to SDP
Adding non-codec 0x1 (telephone-event) to SDP
<--- Reliably Transmitting (no NAT) to --->
SIP/2.0 200 OK
Via: SIP/2.0/UDP;branch=z9hG4bK-79eb04ffe8db79dc1c9a1bec67872e62;received=
From: "Russell Cattelan" <sip:16128053144@>;tag=3468510938-450305
To: <sip:16514820379@ss.callcentric.com>;tag=as524972e9
Call-ID: 13715775-3468510938-450277@msw1.telengy.net
Server: Asterisk PBX
Supported: replaces, timer
Require: timer
Session-Expires: -1;refresher=uas
Contact: <sip:17772080931@>
Content-Type: application/sdp
Content-Length: 279

o=root 233148858 233148858 IN IP4
s=Asterisk PBX
c=IN IP4
t=0 0
m=audio 15980 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
Comments:By: Elazar Broad (ebroad) 2009-11-30 13:40:38.000-0600

Can you post the relevant portion of your sip.conf? Thanks!

By: Russell Cattelan (cattelan) 2009-11-30 14:19:02.000-0600

Here is the section for callcentric


This is a freepbx box so the context from here on out is generated.
I can post more if needed but it is quite long.

By: Elazar Broad (ebroad) 2009-11-30 15:17:49.000-0600

Can you try adding port=5080 to the peer definition? Thanks!

By: Mark Petersen (roadkill) 2009-11-30 15:30:39.000-0600

can you add the [general] sektion as well
as det default port in asterisk i 5060
there shout be an entry like this

or you need to edit your registre string

taken from http://www.voip-info.org/wiki/view/Asterisk+config+sip.conf

register => user[:secret[:authuser]]@host[:port][/extension]

register => fromuser@fromdomain:secret@host

register => fromuser@fromdomain:secret:authuser@host:port/extension

By: Russell Cattelan (cattelan) 2009-11-30 15:45:47.000-0600

I did try port=5080 at one point but it didn't help.

The problem does no appear to be with registration, that all seems
to work fine, and out going calls work fine.

it's just the point in the communication where asterisk is trying to tell
callcentric that it answered the phone -- that message never seems to get
to callcentric.

sip show registry shows the system is registered and looks normal ... well at least in comparison to 1.4

so callcentric will accept registrations on port 5060 but it appears it wants sip conversations to happen on 5080 and for whatever reason 1.6 appears to be ignoring that.

By: Elazar Broad (ebroad) 2009-11-30 16:26:51.000-0600

Can you post a full sip debug? Thanks!

By: Elazar Broad (ebroad) 2009-12-01 10:46:23.000-0600

Can you post the invite from callcentric on 1.6(I don't see it in the debug)? Additionally, it looks like a FreePBX script is corrupting some critical SIP headers, i.e most devices don't like 'Use of uninitialized value ... /var/www/html/panel/op_server.pl line n.' in their Contact header or SDP. With that said, we do not support FreePBX, you will need to contact them for support. It is quite difficult to troubleshoot this issue if the SIP messages are mangled, however, I will keep this open since first glance looks like Asterisk may not be honoring the port returned by a DNS SRV lookup. I really need to see the invite sent by callcentric(I have a feeling they are sending 5060 in the contact header). Thanks!

By: Russell Cattelan (cattelan) 2009-12-02 14:43:18.000-0600

sorry for the delay.
I'm setting another vm so I can keep my working 1.4 system in one piece
and be able to switch back and forth and compare debug info.

By: Russell Cattelan (cattelan) 2009-12-05 19:10:43.000-0600

Ok I now have 2 mostly identical setups.
One running fedora12 asterisk 1.4 and freepbx 2.6
another running fedora12 asterisk 1.6.1 and freepbx 2.6

The config on the 1.6 box was done by doing a freepbx backup on
the 1.4 box and a config restore on the 1.6 box so things should be set
up the same.

I have attached both sip debug traces after doing a "reload" on each box.

Let mw know if there is some specific info that should be extracted -- I can
flip things back and forth to see how things behave differently.

By: Elazar Broad (ebroad) 2009-12-07 11:30:44.000-0600

I need a debug with a conversation, i.e. INVITE in it...

By: dant (dant) 2009-12-09 01:05:56.000-0600

Interestingly in 'reload' you can see that registration appears to be happening to 'callcentric.com' and a SRV lookup is done which gets a hostname and port (5080), the hostname is resolved to an IP and the registration starts, but, sent to port 5060. This would appear wrong...

In 'reload1.4' the register appears as if the port may have been specified in the register line to port 5080, but, the start of registration is missing from the file so it's hard to say.

NAT does appear to be in play here and NAT 'mode' doesn't appear active on 1.6 while it does on 1.4... The 200 response on 1.6 does have an SDP that's full of which is another major difference between the two...

I'd suggest that is might actually work if the NAT issues are resolved, but, there may still be a problem with 1.6 handling of the port from SRV lookup when doing REGISTER...

By: Elazar Broad (ebroad) 2009-12-09 12:35:19.000-0600

Do you have 'localnet' configured in 1.6.1?

By: Russell Cattelan (cattelan) 2009-12-10 00:04:04.000-0600

I remember trying both localnet and externip (set to external ip on my firewall)
I don't remember if the behavior changed but I do remember it not fixing
the problem.

Currently I do not have it defined, and the attached logs are also without
it defined.

By: Elazar Broad (ebroad) 2009-12-10 12:29:50.000-0600

Please configure localnet with your local subnet, and set externip as you stated above.

By: Russell Cattelan (cattelan) 2009-12-12 14:34:13.000-0600

adding that to the sip config does not appear to change the behavior in this case

By: Elazar Broad (ebroad) 2009-12-16 13:57:51.000-0600

I am unable to reproduce this. I built Asterisk from source(release), and I get the following when using the peer definition that you posted:
[Dec 16 14:54:16] VERBOSE[19773] dnsmgr.c: [Dec 16 14:54:16]        > doing dnsmgr_lookup for 'callcentric.com'
[Dec 16 14:54:16] VERBOSE[19773] srv.c: [Dec 16 14:54:16]        > ast_get_srv: SRV lookup for '_sip._UDP.callcentric.com' mapped to host alpha7.callcentric.c
om, port 5080
[Dec 16 14:54:16] VERBOSE[19773] dnsmgr.c: [Dec 16 14:54:16]     -- adding dns manager for 'callcentric.com'
[Dec 16 14:54:16] VERBOSE[19773] chan_sip.c: [Dec 16 14:54:16] REGISTER 11 headers, 0 lines
[Dec 16 14:54:16] VERBOSE[19773] chan_sip.c: [Dec 16 14:54:16] Reliably Transmitting (no NAT) to
REGISTER sip:callcentric.com:5080 SIP/2.0
Via: SIP/2.0/UDP xx.xx.xx.xx:5060;branch=z9hG4bK6520a446;rport
Max-Forwards: 70
From: <sip:17772080931@callcentric.com>;tag=as1f81a307
To: <sip:17772080931@callcentric.com>
Call-ID: 769e86760b15851d1af577803ef9bd81@asterisk
User-Agent: Asterisk PBX
Expires: 120
Contact: <sip:17772080931@xx.xx.xx.xx>
Content-Length: 0

[Dec 16 14:54:16] VERBOSE[19773] chan_sip.c: [Dec 16 14:54:16]
<--- SIP read from UDP:// --->
SIP/2.0 407 Proxy Authentication Required
v: SIP/2.0/UDP xx.xx.xx.xx:5060;branch=z9hG4bK6520a446;rport=5060
f: <sip:17772080931@callcentric.com>;tag=as1f81a307
t: <sip:17772080931@callcentric.com>
i: 769e86760b15851d1af577803ef9bd81@asterisk
Proxy-Authenticate: Digest realm="callcentric.com", domain="sip:callcentric.com", nonce="2cda473a49e42f9b6b9068b09582e891", opaque="", stale=TRUE, algorithm=M
l: 0

so...I am not sure where to go from here. Can you post your entire sip.conf?

By: Russell Cattelan (cattelan) 2009-12-17 14:43:47.000-0600

Lets go back to the original hypothesis of why things are not working.
It appears to me that for some reason 1.6 is not honoring the 5080 port
callcentric is expecting.

So not knowing that much about asterisk internals where is the number stored?
maybe there is bug with how things are looked up and 1.6 is simply defaulting
back to 5060?

By: Elazar Broad (ebroad) 2009-12-17 15:34:00.000-0600

The only thing that I see which could possibly affect this is that issuing a 'sip show peer callcentric' in the CLI shows the port as 5060 as opposed to 5080, I haven't studied the code much, but it is possible that Asterisk is storing 5060 for that host, and maybe using it later on. As far as the port that is used for registration, a cursory look at the code shows that the port returned in a SRV lookup would override the port specified in port=foo or a port specified as host:port in a register=> line. With that said, in my tests, honored the port returned by a SRV lookup. As I stated previously, a look at your sip.conf would help troubleshoot this further. You can obscure portions that are private/irrelevant, or mark the issue private so that only manager+ can view it. Thanks!

By: Leif Madsen (lmadsen) 2010-01-07 11:27:16.000-0600

Can you try this again with the latest branch? I thought I had seen another issue about the port not being respected, but I can't seem to find it, which means it "may" have already been committed with a fix.

By: adam dahlquist (adahlquist) 2010-02-12 12:09:56.000-0600

I have run into the same issue when upgrading from asterisk 1.4 to  

My provider bandtel requires us to specify the port that they communicate with to be included in the contact header portion of the registration.  In 1.4 i solved this by adding bindport=506X in my sip_general_custom.conf (i am using freepbx).  As soon as i upgraded to (installing from source and copying /etc/asterisk from 1.4) i noticed that their invites were coming in on 5060 (default port) so i checked the contact header, and sure enough it has reverted to blank (default 5060). I also noticed that the via has changed to 5060 as well which seems to be causing cattelan problems.

Is there another way to get the port number into the contact header to satisfy bandtel, or is this an Asterisk 1.6 bug?

By: Elazar Broad (ebroad) 2010-02-12 12:49:29.000-0600

What port do you have Asterisk listening on? Additionally, is NAT enabled?

By: adam dahlquist (adahlquist) 2010-02-12 13:04:14.000-0600

Nat is enabled.  With the bindport=5063 does that not mean it's listening on 5063.  All of my sip phones, and our application are registered with it on 5063, and it only seems to accept invites on that port as well.  Let me know if there are any configs or packets you want to see, and i can get them together.

By: Elazar Broad (ebroad) 2010-02-12 13:11:50.000-0600

Then it should use 5063, Ill look into why its not. In the meantime, try setting externip/host with 5063 as the port.

By: adam dahlquist (adahlquist) 2010-02-12 13:43:22.000-0600

I tried that and it didnt make a difference. I also have port=5063 in peer details, and in the fromdomain i have host:5063.  Also have port=5063 in sip general.  Here is my registration from a 1.4 asterisk box:

User Datagram Protocol, Src Port: 5061 (5061), Dst Port: sip (5060)
Session Initiation Protocol
   Request-Line: REGISTER sip:registrar.bandtel.com SIP/2.0
   Message Header
       Via: SIP/2.0/UDP my.ip.com:5061;branch=z9hG4bK3be99106;rport
           Transport: UDP
           Sent-by Address: my.ip.com
           Sent-by port: 5061
           Branch: z9hG4bK3be99106
           RPort: rport
       From: <sip:AOR@registrar.bandtel.com>;tag=as18fc8ea9
       To: <sip:AOR@registrar.bandtel.com>
       Call-ID: 5fd472234efe1da5762da6ef2842c4ea@
       CSeq: 784 REGISTER
           Sequence Number: 784
           Method: REGISTER
       User-Agent: Asterisk PBX
       Max-Forwards: 70
       Authorization: Digest username="AOR", realm="", algorithm=MD5, uri="sip:registrar.bandtel.com", nonce="4b74955a810dd1992795b5b175596020aae65ca0", response="af404f1d9aa3f34704278b3786ef91e2"
           Authentication Scheme: Digest
           Username: "AOR"
           Realm: ""
           Algorithm: MD5
           Authentication URI: "sip:registrar.bandtel.com"
           Nonce Value: "4b74955a810dd1992795b5b175596020aae65ca0"
           Digest Authentication Response: "af404f1d9aa3f34704278b3786ef91e2"
       Expires: 120
       Contact: <sip:AOR@my.ip.com:5061>
       Event: registration
       Content-Length: 0

And here is one from my 1.6 box which has the same config (VM image was replicated and asterisk updated)

User Datagram Protocol, Src Port: 5063 (5063), Dst Port: sip (5060)
Session Initiation Protocol
   Request-Line: REGISTER sip:registrar.bandtel.com SIP/2.0
   Message Header
       Via: SIP/2.0/UDP my.ip.com:5060;branch=z9hG4bK14588a4e;rport
           Transport: UDP
           Sent-by Address: my.ip.com
           Sent-by port: 5060
           Branch: z9hG4bK14588a4e
           RPort: rport
       Max-Forwards: 70
       From: <sip:AOR@registrar.bandtel.com>;tag=as79b7fda4
       To: <sip:AOR@registrar.bandtel.com>
       Call-ID: 5f8d846018fe5bc579a77c025e60f8c7@
       CSeq: 173 REGISTER
           Sequence Number: 173
           Method: REGISTER
       User-Agent: Asterisk PBX
       Authorization: Digest username="AOR", realm="", algorithm=MD5, uri="sip:registrar.bandtel.com", nonce="4b75ac2cc400324fc2ab5f80e7d5ad072fbdfd33", response="c5cd8f5bc3a5c6b134272b6b5987e328"
           Authentication Scheme: Digest
           Username: "AOR"
           Realm: ""
           Algorithm: MD5
           Authentication URI: "sip:registrar.bandtel.com"
           Nonce Value: "4b75ac2cc400324fc2ab5f80e7d5ad072fbdfd33"
           Digest Authentication Response: "c5cd8f5bc3a5c6b134272b6b5987e328"
       Expires: 120
       Contact: <sip:AOR@my.ip.com>
       Content-Length: 0

You can see that my source port is correct in both cases.

Please let me know as soon as you have an idea if this is a bug in asterisk so i can set expectations as to where the roadblock is on my end.  Thanks a lot for your help and prompt replies on this issue.

By: Elazar Broad (ebroad) 2010-02-13 23:36:10.000-0600

Just to clarify, you are trying to contact Bandtel on 5063 as opposed to 5060? What does your register line look like?

By: adam dahlquist (adahlquist) 2010-02-15 10:18:51.000-0600

I am communicating with Bandtel on their 5060, but am receiving on my 5063.  They require us to specify the port that we are receiving on to be part of the contact header. Here is my register line:


By: adam dahlquist (adahlquist) 2010-02-15 11:02:30.000-0600

You can see above that my 1.4 box has the bindport (5061 in this case) in the contact header and the via line whereas my 1.6 box does not. You can see that the src port is 5061 in the 1.4 packet and 5063 in the 1.6.

By: Elazar Broad (ebroad) 2010-02-15 11:07:03.000-0600

adahlquist, I believe your issue is different than the one reported by the OP. Please open a new issue. Thanks!

By: adam dahlquist (adahlquist) 2010-02-15 12:01:18.000-0600

Ok done. https://issues.asterisk.org/view.php?id=16827

By: Leif Madsen (lmadsen) 2010-03-23 12:33:03

Is this still an issue on the most recent version of 1.6.2?

By: Russell Cattelan (cattelan) 2010-03-24 11:43:41

Thanks for the reminder.
I need to find a time to update my test box and try it again.

I have been running 1.4 and haven't had a chance to bring things down
to do more testing.

I will find a window soon.

By: Russell Cattelan (cattelan) 2010-04-11 10:41:04

Ok tested with the latest code.
[cattelan@pbx-test asterisk]# asterisk -V
Asterisk SVN-trunk-r256704

Same issue still will not answer a phone call.
outgoing calls work so most of the connection configuration works just fine.

But it still does not answer the call.

I'm attaching the sip debug trace for both 1.4 and 1.6

By: Russell Cattelan (cattelan) 2010-11-06 13:11:33

So I finally spent some time and added a bunch of debug prints and I think I finally
tracked down the issue. I *think* the issue is with the addition of socket.port.

The code correctly looks up the port number from the dns and populates the addr.sin_port but
the defaddr and the socket.port is set to the default sip port .

I'm not sure if both the defaddr socket.port should be set to addr.sin_port but it appears to be working
the that way.

Index: asterisk-1.6.2/channels/chan_sip.c
--- asterisk-1.6.2.orig/channels/chan_sip.c
+++ asterisk-1.6.2/channels/chan_sip.c
@@ -24457,15 +24457,13 @@ static struct sip_peer *build_peer(const

- if (!peer->addr.sin_port) {
+ if (!peer->addr.sin_port)
peer->addr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
- }
- if (!peer->defaddr.sin_port) {
- peer->defaddr.sin_port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
- }
- if (!peer->socket.port) {
- peer->socket.port = htons(((peer->socket.type & SIP_TRANSPORT_TLS) ? STANDARD_TLS_PORT : STANDARD_SIP_PORT));
- }
+ if (!peer->defaddr.sin_port)
+ peer->defaddr.sin_port = peer->addr.sin_port;
+ if (!peer->socket.port)
+ peer->socket.port = peer->addr.sin_port;

if (!sip_cfg.ignore_regexpire && peer->host_dynamic && realtime) {
time_t nowtime = time(NULL);

By: Russell Cattelan (cattelan) 2011-02-24 09:38:26.000-0600

Any comments on this issue?
I would like to maybe finally move our install off of 1.4 but would like
to find out if this is a correct fix.


By: Russell Cattelan (cattelan) 2011-06-29 18:03:28.891-0500

Adding another Ping here.
I really would like to get these changes into 1.6 proper vs having to maintain the patch myself

By: David Woolley (davidw) 2011-06-30 13:07:48.217-0500

To submit a patch, you must sign the electronic licence agreement and you must attach it, marked as being code.  This is done so that Digium have documented confirmation that they can use the code in their products.

As 1.6 is no longer supported, I strongly suspect that it is too late to submit a patch properly, but that is a policy decision for Digium.

By: Russell Cattelan (cattelan) 2011-06-30 13:45:08.904-0500

At this point I would just be happy to have somebody who understands
the sip code look at the change and tell me if it the right thing to do
or not. I seems to me the current code is making assumptions and just
settting the port to 5060 even if the remote side is saying use port X

By: Matt Jordan (mjordan) 2011-12-15 09:26:55.367-0600


I have no idea if you're still on the 1.6.2 branch or not.  I can say that a number of things were changed with respect to build_peer in 1.8, so you might be best served by moving to that branch (particularly since its still supported, as opposed to 1.6.2).

As far as your in-comment patch is concerned, patches *need* to be supplied as an attachment to the issue with a License agreement signed, if for no other reason then it is very difficult to view a patch in a comment (the formatting gets all wonky).  If I'm interpreting it correctly - which is to say you want to remove the setting of the ports to default values - that is not the correct thing to do.  Those lines are executed when no port is specified in build_peer - so setting that to something that may or may not exist is probably not correct.

Again, rather then patching 1.6.2 for this issue, I would recommend moving to 1.8.  I do not believe Asterisk in 1.8 and higher has this problem.  If that is not the case, please do reopen this issue.

Since we don't support 1.6.2 any longer, I am going to close this issue as suspended; however, I hope that this feedback helps you move towards a solution for 1.6.2 if you choose to stay on that branch.