datso / react-native-pjsip

A PJSIP module for React Native.
http://datso.github.io/react-native-pjsip
GNU General Public License v3.0
273 stars 229 forks source link

Cannot register behind NAT on Android #180

Open codykociemba opened 5 years ago

codykociemba commented 5 years ago

I'm behind WiFi on my phone, and it seems to go into an endless Register loop when connecting to my Asterisk server. I can see the requests coming back on the Asterisk server, and Asterisk is responding, however it looks like it's not being seen on the client side.

Here is my code:

prepareCall = async () => {
    let configuration = {
      "name": "USERNAME",
      "username": "USERNAME",
      "domain": "sip.domain.com",
      "password": "PASSWORD",
      "proxy": null,
      "transport": "UDP", // Default TCP
      "regServer": "sip.domain.com", // Default wildcard
      "regTimeout": null // Default 3600
    };

    let endpoint = new Endpoint();
    let state = await endpoint.start({
      service: {
        ua: 'RN SIP',
      },
      network: {
        useWifi: true,
        useOtherNetworks: true,
      },
      service: {
          stun: ['stun.l.google.com:19302','stun4.l.google.com:19302']
      },
  });
    let account = await endpoint.createAccount(configuration).then(acnt => {
      console.log('SIP Account: ', acnt);
    }).catch(error => {
      console.log('SIP Error: ', error);
    });
  }

I can provide the console log, however it's just sending Registers over and over until it times out. It does get the correct IP address for the domain, however it seems to be using the local IP in the Via header and not the public. What could be going wrong? Any help would be greatly appreciated.

vitoraguila commented 5 years ago

@codykociemba Did you fix that?