Intermittent 1 way audio only when registering to OpenSIPs in front of Asterisk

Asterisk 1.8.x

Long time Asterisk user but fairly new to OpenSIPs. I have a SIP phone working with audio both directions when registering to and receiving calls directly from Asterisk. The same phone works with 2 way audio if I register to OpenSIPs and receive a call from OpenSIPs but only IF the call originated from somewhere OTHER than our Asterisk server.

Example that works:

Call from PSTN > OpenSIPs > SIP Phone (registered to OpenSIPs)

Call from PSTN > Asterisk > SIP Phone (registered to Asterisk)

Example that does NOT work, one way audio issues:

Call from PSTN > Asterisk > OpenSIPs > SIP Phone (registered to OpenSIPs)

I am trying to offload all our registrations from Asterisk to OpenSIPs but when we pass the call from Asterisk to OpenSIPs the call goes to the phone registered to OpenSIPs but has one way audio.

Don’t believe it to be a firewall issue because we have tested while firewalls on both Asterisk and OpenSIPs are off.

Have tested many theories but, I’m at a loss at this point, out of ideas. I thought I would ask the smart folks here.

I fixed a lot of the one way audio issues by setting nat=yes in the sip.conf on Asterisk server under the configuration for the OpenSIPs server context [opensipsserver].

I noticed that when I tested on a newer version of Asterisk I got better errors in the Asterisk console. I noticed Asterisk was trying to send the RTP to the private LAN IP of the endpoint (my sip phone) instead of the public IP of my internet connection where the phone is located. Not sure why it was trying to do that. I am wondering if OpenSIPs needs to be modified. Was puzzles me is that I have NEVER had to set nat=yes on Asterisk when sending calls to servers with static public IP. In this case I am sending calls to an extension like 456@xxx.xxx.xxx.xxx where xxx is the public static IP of my OpenSIPs server so, no NAT involved there. The NAT comes into play when the call is sent to the endpoint which is behind a NAT. Makes no sense to me why I should have to set nat=yes to make this work but, this was an immediate fix for most of the issues. Will research more later, might need a change on the OpenSIPs side instead of nat=yes on the Asterisk side.

While most of the audio works now, we still have odd issues such as a soft-phone having no audio or one way audio while a hardware based phone (both sitting behind the same NAT) works perfectly every time.

We also have the same model hardware phones that work perfect for 2 end users but another end user has one way audio on only SOME calls.

Thanks in advance for any help.

Do you have any captures of the signaling on a failed call?