C++ 尝试通过NAT注册pjsua2时失败

C++ 尝试通过NAT注册pjsua2时失败,c++,qt,nat,pjsua2,C++,Qt,Nat,Pjsua2,我正在尝试在pabx sip上注册pjsua2(pjsip),当没有nat时,该注册可以正常工作,但当有nat时,它不注册 bool sipcount::start(){ 此->ep.libCreate(); //初始化端点 this->ep.libInit(this->ep_cfg); //创建SIP传输。显示错误处理示例 此->tcfg.port=此->端口; 试一试{ 此->ep.transportCreate(PJSIP\u TRANSPORT\u UDP,此->tcfg); }捕获(错

我正在尝试在pabx sip上注册pjsua2(pjsip),当没有nat时,该注册可以正常工作,但当有nat时,它不注册

bool sipcount::start(){
此->ep.libCreate();
//初始化端点
this->ep.libInit(this->ep_cfg);
//创建SIP传输。显示错误处理示例
此->tcfg.port=此->端口;
试一试{
此->ep.transportCreate(PJSIP\u TRANSPORT\u UDP,此->tcfg);
}捕获(错误和错误){
std::cout acfg.callConfig.timerMinSESec=120;
此->acfg.callConfig.timersesexpiressec=1800;
this->cred.username=this->username.toLatin1().data();
此->cred.scheme=“摘要”;
此->cred.realm=“*”;
此->cred.dataType=0;
this->cred.data=this->password.toLatin1().data();
this->acfg.sipConfig.authCreds.push_back(this->cred);
//设置帐户
SipLine*l=新的SipLine();
l->setHandler(此->处理程序);
l->创建(acfg);
//在这里,我们没有别的事可做。。
该->行=l;
//pj_线程_睡眠(10000);
返回true;
}
我的问题是rport使用pjsip,我没有设置凭据,用于通信的端口无效

这是来自测试中使用的标题的样本


使用NAT(网络地址转换)时,您实际上没有对等方可以连接回的公共IP(至少不是没有额外的工作/复杂)。NAT不是互联网的工作方式-这是一个丑陋的黑客。@JesperJuhl我的问题是使用库pjsip,通信有错误。缺少一些东西。
bool SipAccount::start(){
    this->ep.libCreate();
    // Initialize endpoint
    this->ep.libInit(this->ep_cfg );

    // Create SIP transport. Error handling sample is shown
    this->tcfg.port = this->port;
    try {
        this->ep.transportCreate(PJSIP_TRANSPORT_UDP, this->tcfg);
    } catch (Error &err) {
        std::cout << err.info() << std::endl;
        return false;
    }

    // Start the library (worker threads etc)
    this->ep.libStart();
    std::cout << "*** PJSUA2 STARTED ***" << std::endl;

    // Configure an AccountConfig


    this->acfg.idUri = idUri.toLatin1().data();
    this->acfg.regConfig.registrarUri =  regUri.toLatin1().data();

    this->acfg.callConfig.timerMinSESec = 120;
    this->acfg.callConfig.timerSessExpiresSec = 1800;

    this->cred.username = this->username.toLatin1().data();
    this->cred.scheme = "digest";
    this->cred.realm = "*";
    this->cred.dataType = 0;
    this->cred.data = this->password.toLatin1().data();

    this->acfg.sipConfig.authCreds.push_back( this->cred );

    // Setup the account
    SipLine *l = new SipLine();
    l->setHandler(this->handler);
    l->create(acfg);

    // Here we don't have anything else to do..
    this->line = l;
    // pj_thread_sleep(10000);
    return true;
}