[Resolved] Badly formed SIP message outgoing Nextiva call

I am a newbie to Asterisk, so please excuse any dumb mistakes. I read the FAQ and think I am posting as recommended.

The error could be a bad configuration file or a real problem. In any event, it seems that any configuration file error that can cause a malformed SIP message should have an edit. So, I am reporting.

Any help resolving this will be most appreciated. I’m a stumped chump.

Problem description: [color=#0000FF]Cannot place Nextiva SIP trunk call due to badly formed SIP message. Extension to extension calls work fine. Incoming calls from Nextiva work fine.[/color]
Error Message: [color=#0000FF] Got SIP response 400 “Sip message body is shorter that is indicated by the content length” back from xxx.yyy.zzz.95:5060[/color]
Asterisk version: [color=#0000FF]10.0.0[/color]
OS Version: [color=#0000FF]CentOS 6.0, minimal server install with required packages added[/color]
Test phone: [color=#0000FF]X-Lite 4.1[/color]
Other Notes: [color=#0000FF]I have Cisco 7970G phones with SIP firmware on the network at extensions 101 - 103. Since these are a bit unusual, I added extension 104 as an X-Lite 4.1 client and did all testing with that. I have redacted IP addresses, user IDs, passwords, and phone numbers as recommended.[/color]

Asterisk log showing error on outgoing Nextiva call (failure is noted):

[code][root@Asterisk ~]# asterisk -r
Asterisk 10.0.0, Copyright © 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 10.0.0 currently running on Asterisk (pid = 1725)
Verbosity is at least 5
== Using SIP RTP CoS mark 5
– Executing [91504xxxxxxx@default:1] Dial(“SIP/104-00000037”, “SIP/nextiva/1504xxxxxxx@nextiva,60”) in new stack
== Using SIP RTP CoS mark 5
failed to extend from 1024 to 1299
failed to extend from 1024 to 1311
failed to extend from 1024 to 1303
– Called SIP/nextiva/1504xxxxxxx@nextiva
failed to extend from 1024 to 1299
failed to extend from 1024 to 1311
failed to extend from 1024 to 1303
FAILURE MESSAGE ON NEXT LINE
– Got SIP response 400 “Sip message body is shorter that is indicated by the content length” back from xxx.yyy.zzz.95:5060
– SIP/nextiva-00000038 is circuit-busy
== Everyone is busy/congested at this time (1:0/1/0)
– Auto fallthrough, channel ‘SIP/104-00000037’ status is 'CONGESTION’
Asterisk*CLI> exit
[/code]

Asterisk log of incoming Nextiva call working:

[code][root@Asterisk ~]# asterisk -r
Asterisk 10.0.0, Copyright © 1999 - 2011 Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 10.0.0 currently running on Asterisk (pid = 1725)
Verbosity is at least 5
== Using SIP RTP CoS mark 5
– Executing [s@nextiva:1] Dial(“SIP/nextiva-00000039”, “SIP/101”) in new stack
== Using SIP RTP CoS mark 5
failed to extend from 1024 to 1321
failed to extend from 1024 to 1323
failed to extend from 1024 to 1334
failed to extend from 1024 to 1312
failed to extend from 1024 to 1306
– Called SIP/101
– SIP/101-0000003a is ringing
== Spawn extension (nextiva, s, 1) exited non-zero on 'SIP/nextiva-00000039’
Asterisk*CLI> exit
[/code]

sip.conf:

[code][general]
context=default ; Default context for incoming calls
port=5060 ; UDP Port to bind to (SIP standard port is 5060)
bindaddr=0.0.0.0 ; IP address to bind to (0.0.0.0 binds to all)
;srvlookup=yes ; Enable DNS SRV lookups on outbound calls
localnet=192.168.1.0/255.255.255.0
register => :@xxx.yyy.zzz.95:5060 ; Register with Nextiva

[nextiva]
type=friend
secret=
username=
host=xxx.yyy.zzz.95
dtmfmode=rfc2833
qualify=yes
nat=yes
qualify=yes
canreinvite=no
disallow=all
allow=all
allow=alaw
allow=gsm
fromdomain=xxx.yyy.zzz.95
fromuser=
defaultuser=
insecure=port,invite
context=nextiva

[101]
type=friend ; both send and receive calls from this peer
host=dynamic ; this peer will register with us
;username=101
secret=
;canreinvite=no ; don’t send SIP re-invites (ie. terminate rtp stream)
nat=no ; always assume peer is behind a NAT
;context=phones ; send calls to ‘phones’ context
;dtmfmode=rfc2833 ; set dtmf relay mode
allow=all ; allow all codecs

[102]
type=friend ; both send and receive calls from this peer
host=dynamic ; this peer will register with us
;username=102
secret=
;canreinvite=no ; don’t send SIP re-invites (ie. terminate rtp stream)
nat=no ; always assume peer is behind a NAT
;context=phones ; send calls to ‘phones’ context
;dtmfmode=rfc2833 ; set dtmf relay mode
allow=all ; allow all codecs

[103]
type=friend ; both send and receive calls from this peer
host=dynamic ; this peer will register with us
;username=103
secret=
;canreinvite=no ; don’t send SIP re-invites (ie. terminate rtp stream)
nat=no ; always assume peer is behind a NAT
;context=phones ; send calls to ‘phones’ context
;dtmfmode=rfc2833 ; set dtmf relay mode
allow=all ; allow all codecs

[104]
type=friend ; both send and receive calls from this peer
host=dynamic ; this peer will register with us
;username=104
secret=
;canreinvite=no ; don’t send SIP re-invites (ie. terminate rtp stream)
nat=no ; always assume peer is behind a NAT
;context=phones ; send calls to ‘phones’ context
;dtmfmode=rfc2833 ; set dtmf relay mode
allow=all ; allow all codecs
[/code]

externsion.conf

[code][general]
static=yes ; default values for changes to this file
writeprotect=no ; by the Asterisk CLI

[globals]
; variables go here

[default]
; default context
exten => 999,1,Answer()
exten => 999,2,Playback(vm-nobodyavail)
exten => 999,3,Hangup()

exten => _1XX,1,Dial(SIP/${EXTEN})

; Call POTS numbers through Foo Provider (any number longer than 5 digits starting with 9)

exten => _9XXXX.,1,Dial(SIP/nextiva/${EXTEN:1}@nextiva,60)

[nextiva]
exten => s,1,Dial(SIP/101)
exten => s,n,Hangup()[/code]

Either you are critically short of memory, or you have hit an implementation limit. It is trying to grow a string beyond 1KB and has failed, either because the string is in memory allocated from a source that doesn’t allow it to be extended, or because an attempt to allocate a larger buffer failed, through lack of memory.

A sip debug trace may have helped to identify why the request is unusually long.

Note that beyond a certain size, you will get IP fragmentation, which is not, generally, a good thing.

Thanks for the thoughtful reply. I had originally seen that message as having something to do with the extension patterns, but now see as a warning that lead to the malformed SIP message. The best way for a newbie to get experience is to work problems. Based on your observations, I will work on the problem as a memory issue. If I solve it, I will post the solution. If I get stumped again, I will post more documentation.

I now see I should have included the following in my original problem description:

Hosting Environment: [color=#0000FF]Dedicated (not virtual) HP Pavillion p7-1154 (h10025.www1.hp.com/ewfrf/wc/docu … ct=5157024) with AMD processor and 6GB RAM. Only software running on machine other than Asterisk related software is a small TFTP server to load the Cisco 7970G phones.[/color]

Thanks again for pointing me in the right direction.

I think it is more likely to be a fixed limit than memory starvation.

The string building routines support three types of memory allocation:

Static (probably includes named arrays on the stack).
Dynamically allocated from the stack using alloca.
Dynamically allocated from the heap.

Only the last case can be dynamically extended.

Thanks for the additional info. It will help me focus my efforts I will focus on getting Asterisk to use dynamic allocation.

Regards

(second attempt at posting resolution)

The problem was an incorrect sip.conf. It took about two months to talk Nextiva support out of their guide. Once you have that it is easy to configure sip.conf.

Here is the correct, redacted sip.conf which can be compared to the original posted above:

[code][general]
context=default
allowoverlap=no
bindport=5060
disallow=all
allow=ulaw

register => :@ ; Register with Nextiva

[nextiva]
type=friend
disallow=all
allow=ulaw
username=
fromuser=
secret=
qualify=no
context=nextiva
maxexpirey=3600
host=
fromdomain=
insecure=invite
dtmfmode=rfc2833
session-timers=refuse
defaultexpirey=60
nat=no
canreinvite=no[/code]

canreinvite is deprecated and should be directmedia. directmedia should be acceptable to all versions of asterisk that don’t understand port, invite on insecure.