< Previous by Date Date Index Next by Date >
  Thread Index  

[reSIProcate-users] get address for STUN problem


Hi all,

as per the snippet in the docs i made a simple implementation of the getStunAddress as follows.

however i noticed a few things...


1) on windows (VS2010SP1, resip 1.10.2) if the line (7) before checking for an existing result is commented, then no STUN request is ever done at all, while adding that line i can see 2 requests. This seems a bug in the windows implementation since on mac (at least, i've not tried on linux yet) the first stun request is done as expected. (without the one outside the if)

2) i see (from wireshark trace) that between the dns query response of stun server and the initial stun request pass 6-10 seconds. (both mac and win) is that normal? What would be the best way to deal with this?

Thanks a lot for any hints / suggestions

-- getStunAddress--

resip::Tuple
ReSipHandler::getStunAddress()
{
    resip::Tuple mMappedAddress;
    mMappedAddress.setPort(0);
    resip::UdpTransport *m_pUdpTransport = dynamic_cast<UdpTransport*>(m_resipUsedTransportPtrVec.at(0));

    if (!m_pUdpTransport) return mMappedAddress;

    //this->sendStunTest(); //<-- without this on windows there's NO 
    if (!m_pUdpTransport->stunResult(mMappedAddress))
    {
         // no valid result available, send another request
         this->sendStunTest();
    }

    qDebug() << Q_FUNC_INFO << QDateTime::currentDateTime();
    while (true)
    //while ((GetTickCount() - dwTmpLastStunTestTime) < 5 * 1000) // wait 5s for result
    {
        static int count = 0;
        qDebug() << "Cheking if result arrived..." << QDateTime::currentDateTime();
        if (m_pUdpTransport->stunResult(mMappedAddress)) {
            qDebug() << "DUM reported to have a valid STUN address";
            break;
        }

        qDebug() << "Sleeping..." << QDateTime::currentDateTime();
        Sleep(500);
        qDebug() << "Waking up..." << QDateTime::currentDateTime();
        count++;
        if (count == 20) {
            count = 0;
            qDebug() << "Breakng out of loop due to timeout";
            break;
        }
    }

    return mMappedAddress;
}