PJSIP Trunk Hangup/Hold Issues

Hi, I have configured a Panasonic KX-HDV230, Panasonic KX-HDV130, an Ekiga softphone, and a SIP trunk from Sipgate using the PJSIP Wizard.

I can make calls between the phones/softphone fine, including putting calls on hold, and transferring calls.

I can make calls to/from the trunk to/from the phones with audio, however I am getting some strange behavior.

When making calls between a trunk and a SIP phone (e.g. using a mobile phone), if either side hangs up, the call will still be active at the other side. (e.g. if mobile hangs up, SIP phone is still showing an active call, and “core show channels” is showing a call taking place, or if SIP phone hangs up, the mobile is still showing a call taking place).

Also if I try to put a call from the trunk on hold (or try to transfer a call), it immediately hangs up.
The phone will say “Line On Hold” briefly on the screen, and beep as normal, but then the call is ended.

Below is my trunk configuration:

[sipgate]
type = wizard
transport = transport-udp
remote_hosts = sipconnect.sipgate.co.uk
sends_registrations = yes
sends_auth = yes
outbound_auth/username = SIPID
outbound_auth/password = SIPPASSWORD
endpoint/context = from-external
aor/qualify_frequency = 30
aor/remove_existing = yes
endpoint/allow = !all,ulaw,alaw
endpoint/from_user = SIPID
endpoint/from_domain = sipconnect.sipgate.co.uk
endpoint/dtmf_mode = rfc4733
endpoint/rewrite_contact = yes
endpoint/timers = yes
endpoint/rtp_symmetric = yes
endpoint/force_rport = yes

Below is a SIP trace from a call where I try to put it on hold and it disconnects:

NUMBERMOBILE = My mobile number removed
NUMBERTRUNK = Incoming trunk number removed
SIPID = Username for trunk removed
MYIP = My external ISP IP
10.0.0.16 = Asterisk PBX
10.0.0.30 = Panasonic KX-HDV230

https://pastebin.com/Vs7nK7QK

We are getting a retransmission of a 200 OK and sending an ACK each time, so the call isn’t really totally up. Your configuration may be breaking it. Try removing the “endpoint/rewrite_contact = yes” from your provider wizard.

1 Like

Wow, really? Such a simple setting.

That has been driving me mad for hours!

Thanks!

What exactly does the rewrite_contact setting do? I only added this as I found it on a sipgate configuration page.

Now that’s working correctly though, I have just noticed that if I put an internal call on hold, I get music playing, however, if I put an external call on hold, I don’t hear music on my mobile.

Are there different settings for different lines?

The rewrite_contact rewrites the Contact address to the source IP address and port for traffic, used if the remote device is behind NAT so it contains the public information. In an ITSP scenario it can screw things up and cause things to get misrouted.

I’d also suggest setting “endpoint/direct_media = no” which may resolve your MOH issue as well.

2 Likes

Ah, thanks for the explanation.

Hmm, I added “endpoint/direct_media = no” to my trunk settings, but I don’t hear any audio at all now.

Would I have to play around with NAT settings?

If your Asterisk is behind NAT you would need to configure the transport as such so it can provide the public IP address in the SIP signaling. Otherwise you will get no media. Previously things were reinviting so media was direct, which could work if one side (like Sipgate) was public. It would also explain why MOH didn’t work.

1 Like

Fair enough, I will have a play around. Thanks for your help.