< Previous by Date | Date Index | Next by Date > |
Thread Index | Next in Thread > |
Hi List, We are trying to establish a SIP session between two UAs which are behind NAT.The SIP proxy server is in the public domain.We are using SER(Sip Express Router) as SIP proxy and REGISTRAR and RTPProxy as the Media Proxy(rtpproxy is also running in the same public IP machine as SER).We are using DUM testClient (BasicCall.cxx) code as the UA code,on both the endpoints. We have observed that when an INVITE is sent by the resiprocate UA(after proper REGISTRATION),it puts the local IP address in the "Contact" header.This is unlike that of a proper SIP client(Bria),which puts the NATted IP corresponding to the endpoint in the "Contact" header. Thus we notice that the resiprocate UA after sending the INVITE gets a "408 Request Timeout" from the SER,after about a minute,and the SIP session gets terminated and the resiprocate UA shuts down.This is not the case with a proper UA client(Bria),where,it does not get a "408 Request Timeout" from SER. Here is the resiprocate UA code that we are using -- int main (int argc, char** argv){ Log::initialize(Log::Cout, resip::Log::Warning, argv[0]); //Log::initialize(Log::Cout, resip::Log::Debug, argv[0]); //Log::initialize(Log::Cout, resip::Log::Info, argv[0]); //Log::initialize(Log::Cout, resip::Log::Debug, argv[0]);#if defined(WIN32) && defined(_DEBUG) && defined(LEAK_CHECK)FindMemoryLeaks fml; { #endif #if !defined(NO_REGISTRATION) if ( argc < 5 ) {cout << "usage: " << argv[0] << " sip:user1 passwd1 sip:user2 passwd2" << endl; return 0;} NameAddr uacAor(argv[1]); Data uacPasswd(argv[2]); NameAddr uasAor(argv[3]); Data uasPasswd(argv[4]); #else NameAddr uacAor; NameAddr uasAor; #endif //set up UACSipStack stackUac; DialogUsageManager* dumUac = new DialogUsageManager(stackUac);dumUac->addTransport(UDP, 12005); SharedPtr<MasterProfile> uacMasterProfile( new MasterProfile);auto_ptr<ClientAuthManager> uacAuth( new ClientAuthManager);dumUac->setMasterProfile(uacMasterProfile); dumUac->setClientAuthManager(uacAuth);
TestUac uac; dumUac->setInviteSessionHandler(&uac); dumUac->setClientRegistrationHandler(&uac); dumUac->addOutOfDialogHandler(OPTIONS, &uac); auto_ptr<AppDialogSetFactory> uac_dsf( new testAppDialogSetFactory);dumUac->setAppDialogSetFactory(uac_dsf); #if !defined(NO_REGISTRATION) //your aor, credentials, etc heredumUac->getMasterProfile()->setDigestCredential(uacAor.uri().host(), uacAor.uri().user(), uacPasswd); //dumUac->getMasterProfile()->setOutboundProxy(Uri("sip:125.20.9.228:5060"));#else uacAor = NameAddr( "sip:UAC@xxxxxxxxx:12005");#endif dumUac->getMasterProfile()->setDefaultFrom(uacAor); dumUac->getMasterProfile()->setDefaultRegistrationTime(3600); //70
#if !defined(NO_REGISTRATION){ SharedPtr<SipMessage> regMessage = dumUac->makeRegistration(uacAor, new testAppDialogSet(*dumUac, "UAC(Registration)"));cout << "Sending register for Uac: " << endl << regMessage << endl;dumUac->send(regMessage); } #else uac.registered = true;#endif bool finishedTest = false; bool stoppedRegistering = false; bool startedCallFlow = false; bool hungup = false;TestShutdownHandler uacShutdownHandler( "UAC"); while (!(uacShutdownHandler.dumShutDown)){ if (!uacShutdownHandler.dumShutDown){ FdSet fdset; stackUac.buildFdSet(fdset); int err = fdset.selectMilliSeconds(resipMin((int)stackUac.getTimeTillNextProcessMS(), 50));assert ( err != -1 ); stackUac.process(fdset); while(dumUac->process());} if (!(uac.done)){ if (uac.registered && !startedCallFlow){ if (!startedCallFlow){ startedCallFlow = true;#if !defined(NO_REGISTRATION)cout << "!!!!!!!!!!!!!!!! Registered !!!!!!!!!!!!!!!! " << endl;#endif // Kick off call flow by sending an OPTIONS request then an INVITE request from the UAC to the UAS // cout << "UAC: Sending Options Request to UAS." << endl; // dumUac->send(dumUac->makeOutOfDialogRequest(uasAor, OPTIONS, new testAppDialogSet(*dumUac, "UAC(OPTIONS)"))); // Should probably add Allow, Accept, Accept-Encoding, Accept-Language and Supported headers - but this is fine for testing/demonstrationcout << "UAC: Sending Invite Request to UAS." << endl;dumUac->send(dumUac->makeInviteSession(uasAor, uac.mSdp, new testAppDialogSet(*dumUac, "UAC(INVITE)")));} } #if 0 // Check if we should hangup yet if (bHangupAt!=0){ if (time(NULL)>bHangupAt && !hungup){ hungup = true;} } #endif } else{ if (!stoppedRegistering){ finishedTest = true;stoppedRegistering = true;dumUac->shutdown(&uacShutdownHandler); #if !defined(NO_REGISTRATION)uac.registerHandle->stopRegistering(); #endif } } } // OK to delete DUM objects now delete dumUac;cout << "!!!!!!!!!!!!!!!!!! Successful !!!!!!!!!! " << endl;#if defined(WIN32) && defined(_DEBUG) && defined(LEAK_CHECK)} #endif } We are running the binary using the cmdline -- "./BasicCall sip:user1@<public IP of SER> <user1 passwd> user2@@<public IP of SER> <user2 passwd>" Please also let us know if this code is sufficient for creating a SIP session. Rgds Sourav |