PJSUA + ASTERISK NAT problem

I have asterisk + pjsua on my localnetwork woeking perfectly but the problem comes when i put asterisk on public ip and pjsua softphone in a private network behind nat. i cannot receive call and there is no any sound that can be herd. i have tried to add ice/stun/turn on the pjsua softphone without success is there someone who has ever succeded in such a setup?

There are many people who have done such a thing. What is the Asterisk side configuration?

sip.conf
[general]
context = internal
allowguest = no
allowoverlap = no
bindport = 5060
bindaddr = 0.0.0.0
srvlookup = no
disallow = all
allow = ulaw
alwaysauthreject = yes
canreinvite = no
nat = yes
session-timers = refuse
videosupport = yes ; enable Asterisk video support
subscribecontext = default

[2001]
type = friend
host = dynamic
secret = password
context = internal
disallow = all ; better for custom-tunning codec selection
allow = ulaw
allow = alaw
allow = gsm
allow = h263 ; H.263 is our video codec
allow = h263p ; H.263p is the enhanced video codec
dtmfmode = rfc2833 ; inband is not supported in compressed codecs like gsm, so we better set it to rfc2833
canreinvite = no ; canreinvite must be set to ‘no’

[2002]
type = friend
host = dynamic

What is the output of “sip set debug on” and “rtp set debug on” when a call attempt is made?

The server is hosted on amazon web services. the problem is NAT but don’t really know how i can sort it out on pjsua

If it is hosted on AWS then you need to configure Asterisk with the external IP address using externip and localnet.