[pjsip] Creating multiple TCP listeners in PJSUA2

301 at free.fr 301 at free.fr
Mon Jan 16 04:59:56 EST 2017


Hi Aleksandar,

Are you trying to create a new listener on the same IP/port?
Keep in mind that only one instance of an endpoint shall be created.

Regards,
Thibault


2017-01-04 15:49 GMT+01:00 Aleksandar Milenkovic <shark at lotusflare.com>:

> Hello folks,
>
> I'm trying to create multiple TCP listeners in pjsua2 on android using the
> pjproject-2.5.5 release. Thing is, I don't really require many of them, i
> just need to replace the current one with a new instance because Doze mode
> is messing things up.
>
> After returning from Doze mode, I cannot create more TCP listeners and
> thus cannot (re)register anymore, here's the error I'm getting in Java:
>
>
> D/PJSIP: 15:20:41.303    tcptp:47899  SIP TCP transport destroyed
> D/PJSIP: 15:20:41.304   pjsua_core.c  Error creating SIP TCP listener:
> Object with the same type exists (PJSIP_ETYPEEXISTS) [status=171002]
> D/PJSIP: 15:20:41.304   endpoint.cpp  pjsua_transport_create(type, &tcfg,
> &tid) error: Object with the same type exists (PJSIP_ETYPEEXISTS)
> (status=171002) [../src/pjsua2/endpoint.cpp:1614]
> W/System.err: java.lang.Exception: Title:
> pjsua_transport_create(type, &tcfg, &tid)
> W/System.err: Code:        171002
> W/System.err: Description: Object with the same type exists
> (PJSIP_ETYPEEXISTS)
> W/System.err: Location:    ../src/pjsua2/endpoint.cpp:1614
> W/System.err:     at org.pjsip.pjsua2.pjsua2JNI.Endpoint_transportCreate(Native
> Method)
> W/System.err:     at org.pjsip.pjsua2.Endpoint.
> transportCreate(Endpoint.java:178)
> W/System.err:     at org.pjsip.pjsua2.app.MyApp.
> createTransport(MyApp.java:105)
> W/System.err:     at com.packagename.app.calling.MyService.initializeSIP(
> MyService.java:798)
> W/System.err:     at com.packagename.app.calling.MyService.access$1600(
> MyService.java:109)
> W/System.err:     at com.packagename.app.calling.
> MyService$MyBroadcastReceiver.onReceive(MyService.java:1982)
> W/System.err:     at android.app.LoadedApk$ReceiverDispatcher$Args.run(
> LoadedApk.java:1122)
> W/System.err:     at android.os.Handler.handleCallback(Handler.java:751)
> W/System.err:     at android.os.Handler.dispatchMessage(Handler.java:95)
> W/System.err:     at android.os.Looper.loop(Looper.java:154)
> W/System.err:     at android.app.ActivityThread.
> main(ActivityThread.java:6077)
> W/System.err:     at java.lang.reflect.Method.invoke(Native Method)
> W/System.err:     at com.android.internal.os.ZygoteInit$
> MethodAndArgsCaller.run(ZygoteInit.java:865)
> W/System.err:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.
> java:755)
> E/PJSIP: java.lang.Exception: Title:       pjsua_transport_create(type,
> &tcfg, &tid)
>                               Code:        171002
>                               Description: Object with the same type
> exists (PJSIP_ETYPEEXISTS)
>                               Location:    ../src/pjsua2/endpoint.cpp:1614
>
>
> So i've grepped for PJSIP_ETYPEEXISTS and found occurances in
> pjsip/src/pjsip/sip_transport.c and made a small patch in this fashoin:
>
> PJ_DEF(pj_status_t) pjsip_tpmgr_register_tpfactory( pjsip_tpmgr *mgr,
>    pjsip_tpfactory *tpf)
> {
>     pjsip_tpfactory *p;
>     pj_status_t status;
>
>     pj_lock_acquire(mgr->lock);
>
>     /* Check that no factory with the same type has been registered. */
>     status = PJ_SUCCESS;
>     for (p=mgr->factory_list.next; p!=&mgr->factory_list; p=p->next) {
> if (p->type == tpf->type) {
>    /*
>     * SHARK
>     * attempted fix; if a type exists, simply
>     * overwrite it instead of telling me it already exists
>    * status = PJSIP_ETYPEEXISTS;
>    * break;
>    */
>
>    pj_list_insert_after(p, tpf);
>    pj_list_erase(&p);
>    pj_lock_release(mgr->lock);
>    return status;
>
> }
>         //rest of the function ommited
>
> However, I'm still facing the PJSIP_ETYPEEXISTS error and am somewhat
> clueless as to where it's coming from as if the patch didn't have any
> effect which leads me to believe i patched the wrong file or in the wrong
> place
>
> I have also read the archives about a similar-ish problem in a thread
> called "Multiple endpoints" in which a one-liner patch was attached by *Alain
> Totouom *which i cannot find...
>
> Would someone be able to nudge me in the right direction with this issue?
>
> Kind regards, happy new year and merry christmass holidays,
> Aleksandar
>
> _______________________________________________
> 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/20170116/bfb24637/attachment-0002.html>


More information about the pjsip mailing list