Hi, As I said in my announce of CSipSimple, I have a suggestion for current pjsip trunk pjsua module. The problem : Some sip registrar with some specific configuration (that's the case for the french "Freephonie" SIP provider (they use Cirpack)), doesn't allow multiple registration request at the same time. Unfortunately it could happen with current design of pjsua (not in all cases but sometimes, it depends on the server speed I think). It is introduced by the nat detection feature (which is really cool :) ), but when it unregister after the first registration, it send the second registration without waiting for the unregister end. In the case server has not yet finish the treatment of the unregistration, it responds with an error 500 internal error (I think that just after with 200 OK but this OK it is ignored by stack). One possible solution : I found a workaround (I copied a diff below). Not sure that's the better way to handle this problem : in fact, to solve the problem I set a flag at the end of the schedule_reregistration function to say "hey there is a pending reregistration that has to be performed as soon as you'll get the unregistration response". And then in the callback when i get the success of the unregistration I test this flag and if exists, I launch the second register with updated contact. I'm really not sure that this is the better way to handle the problem. (For example what happen if the unregistration failed, should we continue or not? Besides we loss time by waiting for the unregistration response...). Regards, Regis P.S. : sorry for the double post (if any) on my first post (I had a problem with gmail smtp). P.S.2 : also sorry for my english, I hope that it's understandable ;) diff -ur ./pjsip/src/pjsua-lib/pjsua_acc.c /home/r3gis3r/workspaceandroid2/pjsip_android/apps/pjsip/project/pjsip/src/pjsua-lib/pjsua_acc.c --- ./pjsip/src/pjsua-lib/pjsua_acc.c 2010-03-30 13:13:59.000000000 +0200 +++ /home/r3gis3r/workspaceandroid2/pjsip_android/apps/pjsip/project/pjsip/src/pjsua-lib/pjsua_acc.c 2010-04-02 19:53:31.000000000 +0200 @@ -22,7 +22,7 @@ #define THIS_FILE "pjsua_acc.c" - +#define NO_FREEPHONIE_HACK 0 static void schedule_reregistration(pjsua_acc *acc); @@ -718,8 +718,10 @@ /* Unregister current contact */ pjsua_acc_set_registration(acc->index, PJ_FALSE); if (acc->regc != NULL) { +#if NO_FREEPHONIE_HACK pjsip_regc_destroy(acc->regc); acc->regc = NULL; +#endif acc->contact.slen = 0; } @@ -766,13 +768,32 @@ tp->local_name.port = rport; /* Perform new registration */ +#if NO_FREEPHONIE_HACK pjsua_acc_set_registration(acc->index, PJ_TRUE); +#else + acc->has_pending_nat_unregistration = PJ_TRUE; +#endif pj_pool_release(pool); return PJ_TRUE; } +#if !NO_FREEPHONIE_HACK +static pj_bool_t acc_finalize_nat_addr(pjsua_acc *acc, + struct pjsip_regc_cbparam *param) +{ + acc->has_pending_nat_unregistration = PJ_FALSE; + if (acc->regc != NULL) { + pjsip_regc_destroy(acc->regc); + acc->regc = NULL; + //acc->contact.slen = 0; + } + pjsua_acc_set_registration(acc->index, PJ_TRUE); + return PJ_TRUE; +} +#endif + /* Check and update Service-Route header */ void update_service_route(pjsua_acc *acc, pjsip_rx_data *rdata) { @@ -1050,6 +1071,15 @@ PJ_LOG(3,(THIS_FILE, "%s: unregistration success", pjsua_var.acc[acc->index].cfg.id.ptr)); +#if !NO_FREEPHONIE_HACK + if(pjsua_var.acc[acc->index].has_pending_nat_unregistration == PJ_TRUE){ + PJ_LOG(3, (THIS_FILE, "Treat pending nat re-registartion")); + acc_finalize_nat_addr(acc, param); + /* Update address, don't notify application yet */ + PJSUA_UNLOCK(); + return; + } +#endif } else { /* Check NAT bound address */ if (acc_check_nat_addr(acc, param)) { -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.pjsip.org/pipermail/pjsip_lists.pjsip.org/attachments/20100405/76150da7/attachment.html>