[BUG] Asterisk as Gateway problem with MOH

Hello guys I’m facing a very annoying problem. I have my Asterisk 13.22.0 running as Gateway between my SIP provider and my PBX(This PBX has some limitation that its can’t connect SIP directly to SIP provider)

SIP Provider <-------------> Asterisk 13.22.0 <--------------> PBX
SIP PEER SIP PEER

What is happening:

When an extension from my PBX receive or make call it goes through Asterisk and Asterisk redirect to SIP Provider, this flow works fine, the problem is when user use hold from his extension, and try to retrieve his call. When he retrieves his call Asterisk doesn’t re-connect all legs. Asterisk connect PBX and Asterisk leg but the caller still listening Asterisks MOH.

Bellow the flow:
1 - SIP Provider Invite Asterisk
2 - Asterisk Invite PBX
3 - PBX answer Asterisk OK
4 - Asterisk answer SIP Provider OK
5 - Call established
6 - User PBX put extension on hold
7 - Asterisk receive that PBX leg need to be on hold
8 - Asterisk put SIP provider leg on hold
9 - External caller start to listen MOH
10 - User PBX retrieve call
11 - Asterisk re-connect PBX-Asterisk Leg
12 - External caller continue listening MOH

Asterisk Log:

My SIP.conf

[general]
allowguest=no
srvlookup=no
udpbindaddr=0.0.0.0
tcpenable=no
canreinvite=yes
dtmfmode=auto

[trunk_inbound]
context=gw_context
type=peer
host=XX.XX.XX.XX
disallow=all
allow=alaw
nat=no

[trunk_]
context=gw_context
type=peer
host=XX.XX.XX.XX
disallow=all
allow=alaw
nat=no

My extensions.conf
[default]

[gw_context]
exten => 12345.,1,NoOp()
same => n,Dial(SIP/55${EXTEN}@trunk
)
same => n,Hangup()

Should I Update my Asterisk to 15 ?
Or
Try to change to PJSIP ?
Or
Bad configuration ?

Thank you very much !

I can’t see anything relevant wrong with the configuration and Asterisk handles this in older versions.

However as a technical point step 8 cannot happen in chan_sip. Asterisk will start MOH, but it will not sent a=sendonly to indicate a hold.

canreinvite was deprecated many years ago, but you are only getting an internal bridge, so you are obviously doing something that conflicts with it, anyway. It was renamed directmedia.

Hello David !!! First of all thank you for your help. I’ve changed from canreinvite=yes to directmedia=yes and also tested with directmedia=no and without this parameter just to check, but unfortunately nothing changed.

I attached my complete log and I found where the mass start but I still don’t no why it happens.
(File line: 1852 -> START MOH | 3777 -> STOP MOH)

I tested with the exactly configuration that I posted before, so It supposed to be a simple configuration… I don’t guess what could be in conflict…

If you have some light to show me I’m very glad… Thank you !

debug_log_MOH.txt (739.2 KB)

I’ve changed from sip_chan to pjsip_chan and it starts to work.