Sometimes phones don't ring, sometimes no audio?

Get help with installing, upgrading and running Asterisk.

Moderators: muppetmaster, Moderator, Support

Sometimes phones don't ring, sometimes no audio?

Postby zhoujianfu » Sat Jan 09, 2016 12:19 am

Hi!

I'm pretty new to asterisk and probably should have done some more thorough testing before diving in, but now I've got a whole office of polycom phones hooked up through twilio's sip trunking where everybody has their own DID, and I'm starting to have weird problems.

Somewhat sporadically and randomly some phones seem to lose their connection to the asterisk server. When you call the DID, you'll get voicemail after 20 seconds but the polycom will never ring. Rebooting the phone seems to usually fix this.

Also randomly, sometimes the phones will ring, but if you pick up you can't hear anything (the outside caller can hear you though). I discovered restarting asterisk seems to fix this, at least for a while?

Does anybody have some insight into what could be causing these issues? Here's my sip.conf and my extensions.conf, and I'll include an example log of what asterisk spits out during a call when it can't hear the audio.

sip.conf:
[general]
transport=udp

[twilio](!)
type=peer
secret=**********
username=josh
host=samoco.pstn.us1.twilio.com
dtmfmode=rfc2833
canreinvite=no
disallow=all
allow=ulaw
insecure=port,invite
fromdomain=samoco.pstn.us1.twilio.com

[phone](!)
type=friend
host=dynamic
dtmfmode=auto
disallow=all
allow=ulaw
nat=force_rport,comedia

;4248355347
[twilio4248355347](twilio)
fromuser=+14248355347
[4248355347](phone)
context=out4248355347
mailbox=4248355347@default
callerid=4248355347
secret=*********

extensions.conf:
[out4248355347]
exten => asterisk,1,Answer(500)
exten => asterisk,n,VoiceMailMain(s${CALLERID(num)}@default)

exten => 4248355347,1,Answer(500)
exten => 4248355347,n,VoiceMailMain(s${CALLERID(num)}@default)

exten => _1X.,1,Dial(SIP/twilio4248355347/+${EXTEN},60)
exten => _1X.,n,Playtones(congestion)
exten => _1X.,n,Hangup()

exten => _X.,1,Dial(SIP/twilio4248355347/+1${EXTEN},60)
exten => _X.,n,Playtones(congestion)
exten => _X.,n,Hangup()

exten => _+X.,1,Dial(SIP/twilio4248355347/${EXTEN},60)
exten => _+X.,n,Playtones(congestion)
exten => _+X.,n,Hangup()

[default]
exten => +14248355347,1,Dial(SIP/4248355347,20)
exten => +14248355347,n,VoiceMail(4248355347@default,u)

(I repeat all the relevant parts for each of the different numbers in our system)

and here's a dump from when you couldn't hear anything :
-- Executing [+14242740878@default:1] Dial("SIP/samoco.pstn.twilio.com-00000054", "SIP/twilio4242740878/+13109333500&SIP/4242740878,20") in new stack
-- Called SIP/twilio4242740878/+13109333500
-- Called SIP/4242740878
-- SIP/4242740878-00000056 connected line has changed. Saving it until answer for SIP/samoco.pstn.twilio.com-00000054
-- SIP/4242740878-00000056 is ringing
-- SIP/4242740878-00000056 connected line has changed. Saving it until answer for SIP/samoco.pstn.twilio.com-00000054
-- SIP/4242740878-00000056 answered SIP/samoco.pstn.twilio.com-00000054
-- Channel SIP/4242740878-00000056 joined 'simple_bridge' basic-bridge <e0a710a4-4b8c-4270-b24e-731784681082>
-- Channel SIP/samoco.pstn.twilio.com-00000054 joined 'simple_bridge' basic-bridge <e0a710a4-4b8c-4270-b24e-731784681082>
> Bridge e0a710a4-4b8c-4270-b24e-731784681082: switching from simple_bridge technology to native_rtp
> Remotely bridged 'SIP/samoco.pstn.twilio.com-00000054' and 'SIP/4242740878-00000056' - media will flow directly between them
> Remotely bridged 'SIP/samoco.pstn.twilio.com-00000054' and 'SIP/4242740878-00000056' - media will flow directly between them
> 0x35fe1d0 -- Probation passed - setting RTP source address to 72.37.138.210:2228
> 0x369b1c0 -- Probation passed - setting RTP source address to 54.172.60.56:19810
... (I lost a little bit of the end of this one.)

and here's one right after restarting asterisk when it then worked fine:

-- Executing [+14242740878@default:1] Dial("SIP/twilio4242747425-00000003", "SIP/twilio4242740878/+13109333500&SIP/4242740878,20") in new stack
-- Called SIP/twilio4242740878/+13109333500
-- Called SIP/4242740878
-- SIP/4242740878-00000005 connected line has changed. Saving it until answer for SIP/twilio4242747425-00000003
-- SIP/4242740878-00000005 is ringing
-- SIP/twilio4242740878-00000004 is ringing
-- SIP/4242740878-00000005 connected line has changed. Saving it until answer for SIP/twilio4242747425-00000003
-- SIP/4242740878-00000005 answered SIP/twilio4242747425-00000003
-- Channel SIP/4242740878-00000005 joined 'simple_bridge' basic-bridge <32c931f3-6a2b-4642-a1e6-55789b296676>
-- Channel SIP/twilio4242747425-00000003 joined 'simple_bridge' basic-bridge <32c931f3-6a2b-4642-a1e6-55789b296676>
> Bridge 32c931f3-6a2b-4642-a1e6-55789b296676: switching from simple_bridge technology to native_rtp
> Locally RTP bridged 'SIP/twilio4242747425-00000003' and 'SIP/4242740878-00000005' in stack
> Locally RTP bridged 'SIP/twilio4242747425-00000003' and 'SIP/4242740878-00000005' in stack
> 0x7f5ab000f370 -- Probation passed - setting RTP source address to 72.37.138.210:2234
> 0x7f5ab000f370 -- Probation passed - setting RTP source address to 72.37.138.210:2234
> 0x7f5ad00045d0 -- Probation passed - setting RTP source address to 54.172.60.39:15090
-- Channel SIP/4242740878-00000005 left 'native_rtp' basic-bridge <32c931f3-6a2b-4642-a1e6-55789b296676>
-- Channel SIP/twilio4242747425-00000003 left 'native_rtp' basic-bridge <32c931f3-6a2b-4642-a1e6-55789b296676>
== Spawn extension (default, +14242740878, 1) exited non-zero on 'SIP/twilio4242747425-00000003'

When first testing I noticed I couldn't hear anything on the lines when calling in, but I realized we're behind a nat and then added the "nat=force_rport,comedia" line to sip.conf and it started working!

I apologize for the big data dump, but I'm really beyond my depth here and not sure what to do! My hunch is that I haven't really configured things correctly for multiple trunks and multiple sip extensions using twilio and although it sort of works fine for one (or two lines) now that we've got a dozen things are stepping on each other's toes at times? Oh here's a final "sip show peers" dump in case that's of any use?

Name/username Host Dyn Forcerport Comedia ACL Port Status Description
3104398662 (Unspecified) D Yes Yes 0 Unmonitored
3104481413 (Unspecified) D Yes Yes 0 Unmonitored
3104602397/3104602397 72.37.138.210 D Yes Yes 45342 Unmonitored
3104961827 (Unspecified) D Yes Yes 0 Unmonitored
3105260139/3105260139 72.37.138.210 D Yes Yes 5060 Unmonitored
3105260785/3105260785 72.37.138.210 D Yes Yes 27655 Unmonitored
3105260786/3105260786 72.37.138.210 D Yes Yes 5060 Unmonitored
3105260787 (Unspecified) D Yes Yes 0 Unmonitored
3105260788 (Unspecified) D Yes Yes 0 Unmonitored
3105260791 (Unspecified) D Yes Yes 0 Unmonitored
3105260792 (Unspecified) D Yes Yes 0 Unmonitored
3105260804 (Unspecified) D Yes Yes 0 Unmonitored
3105260805/3105260805 72.37.138.210 D Yes Yes 5060 Unmonitored
3105260907 (Unspecified) D Yes Yes 0 Unmonitored
3105262150/3105262150 72.37.138.210 D Yes Yes 4228 Unmonitored
3105262246 (Unspecified) D Yes Yes 0 Unmonitored
3105262248 (Unspecified) D Yes Yes 0 Unmonitored
3105262259 (Unspecified) D Yes Yes 0 Unmonitored
3105262367 (Unspecified) D Yes Yes 0 Unmonitored
3105262369 (Unspecified) D Yes Yes 0 Unmonitored
3105262370/3105262370 72.37.138.210 D Yes Yes 27394 Unmonitored
3105262537/3105262537 72.37.138.210 D Yes Yes 57471 Unmonitored
4242593968/4242593968 72.37.138.210 D Yes Yes 33040 Unmonitored
4242593969 (Unspecified) D Yes Yes 0 Unmonitored
4242688981 (Unspecified) D Yes Yes 0 Unmonitored
4242688982 (Unspecified) D Yes Yes 0 Unmonitored
4242688984 (Unspecified) D Yes Yes 0 Unmonitored
4242740878/4242740878 72.37.138.210 D Yes Yes 40939 Unmonitored
4242747425 (Unspecified) D Yes Yes 0 Unmonitored
4243220114/4243220114 72.37.138.210 D Yes Yes 57521 Unmonitored
4248355347/4248355347 72.37.138.210 D Yes Yes 1236 Unmonitored
twilio3104398662/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3104481413/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3104602397/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3104961827/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3105260139/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105260785/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105260786/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105260787/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3105260788/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105260791/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3105260792/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3105260804/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105260805/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3105260907/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3105262150/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105262246/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio3105262248/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105262259/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105262367/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105262369/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105262370/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio3105262537/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio4242593968/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio4242593969/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio4242688981/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio4242688982/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio4242688984/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio4242740878/josh 54.172.60.0 Auto (No) No 5060 Unmonitored
twilio4242747425/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio4243220114/josh 54.172.60.3 Auto (No) No 5060 Unmonitored
twilio4248355347/josh 54.172.60.0 Auto (No) No 5060 Unmonitored

(only 12 of 31 lines provisioned in asterisk are actually set up with polycom phones so far.)

Thanks so much!!
zhoujianfu
Newsterisk
 
Posts: 2
Joined: Fri Jan 08, 2016 5:51 pm

Re: Sometimes phones don't ring, sometimes no audio?

Postby ambiorixg12 » Sat Jan 09, 2016 6:19 pm

You are missing very important settings , when dealing with NAT

nat = force_rport,comedia ;add this to your general setting or trunks

externaddr =10.0.0.1 ;your public IP
localnet=192.168.0.0/255.255.0.0 ;your localnet
qualify=yes ;to keep the nat session open
rtpkeepalive=<secs> ; Send keepalives in the RTP stream to keep NAT open
; (default is off - zero)

directmedia=no ; Asterisk by default tries to redirect the
; RTP media stream (audio) to go directly from
; the caller to the callee. Some devices do not
; support this (especially if one of them is
; behind a NAT).


Use remotesecret option instead of insecure=invite

The parameter "username" is not the username and in most cases is
not needed at all. Check below. In later releases, it's renamed
to "defaultuser" which is a better name, since it is used in
combination with the "defaultip" setting.


Always use “type=peer” and never “type=friend”
When adding static SIP peers (or so-called “SIP Trunks” in FreePBX/Trixbox) set the type to “peer” and never set it to “friend”. This advice may run counter to the majority of documentation, sample files and examples shown on the voip-info.org site and on Asterisk forums, but you’ll have to take my word for it – using “type=friend” is a big mistake! It will make your Asterisk server much more vulnerable because “type=friend” actually causes two objects to be created – a SIP peer and a SIP user. This gives the potential hacker two entrance doors into your PBX, one of which has comparatively weak security. The problem is that a “user” is allowed to connect from any remote IP address, not just the address specified in the host parameter. Even if you want to allow connections from any address, it is much better to use “host=dynamic” than to use “type=friend”.

By far the worst mistake that you could make when defining a static SIP peer would be to have both “type=friend” and “insecure=invite”. In this situation, a hacker could initiate calls from any remote IP address without needing to authenticate with a password. They would only need to guess one piece of data – the user name.
http://kb.smartvox.co.uk/asterisk/secur ... bx-part-2/


The "canreinvite" option has changed. canreinvite=yes used to disable re-invites if you had NAT=yes. In 1.4, you need to set canreinvite=nonat to disable re-invites when NAT=yes. This is propably what you want. The settings are now: "yes", "no", "nonat", "update". Please consult sip.conf.sample for detailed information.

canreinvite= was renamed to directmedia= in Asterisk 1.6.2 to more accurately describe what this setting does.
ambiorixg12
Astmaster
 
Posts: 967
Joined: Sun Mar 04, 2007 9:32 pm
Location: Dominican Republic

Re: Sometimes phones don't ring, sometimes no audio?

Postby zhoujianfu » Sun Jan 10, 2016 12:32 am

Thank you so much for the thorough reply and all the pointers!

I've made the changes you recommend to the sip config now, and although it's hard to tell right away if it's fixed it all or not, at least nothing seems to have broken! :) I'll follow up on Monday when it should be abundantly clear.

Thanks again!
zhoujianfu
Newsterisk
 
Posts: 2
Joined: Fri Jan 08, 2016 5:51 pm


Return to Asterisk Support

Who is online

Users browsing this forum: Exabot [Bot] and 1 guest