Hi, I have found a viable workaround. Setting a contact explicitly, via force_contact ( http://www.pjsip.org/pjsip/docs/html/structpjsua__acc__config.htm#a5dfdfba40038e33af95819fbe2b896f9). You have to know your external IP address and either hard-code it in or implement some mechanism to discover it. I will later experiment with STUN servers and pjsip's support for STUN for NAT and external IP discovery. It might work even better than forcing the contact. It looks like this: acc_cfg.force_contact = pj_str("<sip:" USER"@" IP_ADDR ":" PORT ";ob>"); The important things are: - you have to include ";ob" at the end. This is a "outbound" parameter/extension. Lack of it caused my first attempt at force_contact to fail and abandon this idea for along time... - USER, IP_ADDR and PORT have to be the same as those found in Via header. This is how OpenIMSCore checks for registration. I defined the port as follows: pjsua_transport_config cfg; pjsua_transport_config_default(&cfg); cfg.port = (pj_uint16_t) SIP_PORT; status = pjsua_transport_create(PJSIP_TRANSPORT_UDP, &cfg, NULL); Hope this helps! Radek 2013/7/18 Rados?aw Szalski <radoslaw.szalski at gmail.com> > Hi, > > > I am currently waiting 5 s, but that is just a magic number I do not have > any solid justification. > > At first, I though simply waiting for status code of last registration to > be (200 OK) would suffice, but it's not the case: > > pjsua_acc_info info; > pjsua_acc_get_info(acc_id, &info); > > while (test.status != 200) { > pjsua_acc_get_info(acc_id, &info); > // some usleep() > } > > After that I wait for the mentioned 5 s. > > ATM I don't have a better solution. I'll get back to you when I finish > what I'm currently working on. > > > 2013/7/18 Gremaud Cyrill <cyrill.gremaud at hefr.ch> > >> Hello Rados ! >> >> Thank you for your reply. This problem is very strange. Actually, I have >> tried and tested your "tricky" solution which consists to send a second >> registration request (with the method pjsua_acc_set_registration(acc_id, >> PJ_TRUE) ) few seconds after the initial REGISTER request send by >> pjsua_acc_add(&acc_cfg, PJ_TRUE, &acc_id). >> >> How many second do you wait before sending the second REGISTER ? >> Sometimes, I wait 3 seconds and it works and sometimes I must waiting more >> because the response has always 2 bindings. This "tricky wait time" depends >> of which parameter(s) ? >> >> If I have more times, I will work on a better way to fix this problem. Do >> you have finding a better solution ? >> >> thanks a lot. cyrill gremaud >> >> >> On Jul 17, 2013, at 9:48 PM, <pjsip-request at lists.pjsip.org> >> wrote: >> >> > Send pjsip mailing list submissions to >> > pjsip at lists.pjsip.org >> > >> > To subscribe or unsubscribe via the World Wide Web, visit >> > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> > or, via email, send a message with subject or body 'help' to >> > pjsip-request at lists.pjsip.org >> > >> > You can reach the person managing the list at >> > pjsip-owner at lists.pjsip.org >> > >> > When replying, please edit your Subject line so it is more specific >> > than "Re: Contents of pjsip digest..." >> > >> > >> > Today's Topics: >> > >> > 1. Re: Status 403 - You must register with a S-CSCF first >> > (Rados?aw Szalski) >> > >> > >> > ---------------------------------------------------------------------- >> > >> > Message: 1 >> > Date: Wed, 17 Jul 2013 21:48:14 +0200 >> > From: Rados?aw Szalski <radoslaw.szalski@xxxxxxxxx> >> > To: pjsip list <pjsip at lists.pjsip.org> >> > Subject: Re: Status 403 - You must register with a S-CSCF >> > first >> > Message-ID: >> > < >> CAFEhLu9kOYSyQdJXdPMiztNHpdKfmeG-q4NQUPn+k46xgZi2jw at mail.gmail.com> >> > Content-Type: text/plain; charset="utf-8" >> > >> > Hi! >> > >> > I have exactly the same problem as you have. Here is my entry for >> > reference: >> > >> http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/2013-May/016297.html >> . >> > Wasn't 100% sure it was a NAT problem back then. >> > >> > >> > Unfortunately I haven't found a reliable solution yet . Indeed, a second >> > registration works correctly (notice that the second time, only 1 >> Contact >> > header is included in REGISTER request and it has the correct, external >> IP >> > address). That's the only lead I have atm. >> > >> > My current workaround is to send, after few seconds after the first, a >> > second REGISTER request using: >> > >> http://www.pjsip.org/pjsip/docs/html/group__PJSUA__LIB__ACC.htm#ga487960dea58d628d92fe4c9a083813de >> > >> > I am working on sending a the modified REGISTER request, containing only >> > the correct Contact header. It involves initializing a REGC structure, >> > setting up the headers and sending the request. This is possible after >> the >> > first registration when we know our external IP address as reported by >> the >> > IMS. Registering for the first time then immediately un-registering and >> > then sending a correct REGISTER request would eliminate the "magic" >> waiting >> > I mentioned before. >> > >> > I also think that the culprit might be the OpenIMSCore itself. I haven't >> > had time to dig through its configuration options and check them all >> > though. What I did test was >> > >> http://www.pjsip.org/pjsip/docs/html/structpjsua__acc__config.htm#a73b69a3a8d225147ce386e310e588285 >> > setting >> > on 1 (legacy) - sends 2 simultaneous REGISTER requests instead of one >> with >> > 2 Contacts. It does not work unfortunately. IMS responds with "Unable to >> > Comply" and its database has to be reset. >> > >> > >> > Please let me/us know when you find a solution. I will report back with >> my >> > finding after I debug some more. >> > >> > >> > >> > 2013/7/17 Gremaud Cyrill <cyrill.gremaud at hefr.ch> >> > >> >> Hello everybody, >> >> >> >> I'm trying to create a simple console application with PJSIP through an >> >> OpenIMSCore which allow Bob and Alice to communication with SIP Message >> >> (IM). >> >> >> >> When I start my application (one for Bob, one for Alice) on my >> computer, >> >> the registration is successful with the OpenIMSCore using the AKAv1-MD5 >> >> authentication and I can send SIP message between Bob and alice. >> >> >> >> But if I start my application from a computer which is behind a NAT >> >> (simple CISCO NAT overload), I have 2 Register request per application >> (one >> >> for the private interface and another one for the public). >> >> >> >> The first Register request is for the private interface and the >> response >> >> (after the challenge) is 200 OK with a "expires = 300. >> >> The second Register request is for the public interface and the >> response >> >> (after the challenge) is 200 OK with a expires = 300 BUT the expire >> for the >> >> private is now a 0. (Wireshark says that there are 2 bindings) >> >> >> >> So, after that, I can't send IM message and I have the message "Status >> 403 >> >> - You must register with a S-CSCF first". >> >> >> >> After 5 minutes, a new Register request is automatically send for the >> >> PUBLIC interface only and after the challenge I have the 200 OK with a >> >> expire = 300 and I have only 1 binding now and I can send IM message. >> >> >> >> Can you help me please ? I have search a lot but with no results. >> Thanks a >> >> lot >> >> >> >> cyrill gremaud >> >> _______________________________________________ >> >> Visit our blog: http://blog.pjsip.org >> >> >> >> pjsip mailing list >> >> pjsip at lists.pjsip.org >> >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> >> >> > -------------- next part -------------- >> > An HTML attachment was scrubbed... >> > URL: < >> http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20130717/c7d0ee2c/attachment.html >> > >> > >> > ------------------------------ >> > >> > Subject: Digest Footer >> > >> > _______________________________________________ >> > pjsip mailing list >> > pjsip at lists.pjsip.org >> > http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> > >> > >> > ------------------------------ >> > >> > End of pjsip Digest, Vol 71, Issue 86 >> > ************************************* >> >> >> _______________________________________________ >> Visit our blog: http://blog.pjsip.org >> >> pjsip mailing list >> pjsip at lists.pjsip.org >> http://lists.pjsip.org/mailman/listinfo/pjsip_lists.pjsip.org >> > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20130801/f2d12ade/attachment-0001.html>