使用PjSip通信的时候,在切换用户的时候经常会报这个错,走过很多弯路,最后才发现是Java GC回收导致对象被销毁:
http://www.pjsip.org/docs/book-latest/html/intro_pjsua2.html#problems-with-garbage-collection
Garbage collection (GC) exists in Java and Python (and other languages, but we don’t support those for now), and there are some problems with it when it comes to PJSUA2 usage:
1.premature destruction of PJSUA2 objects which are created in Java and Python space and passed to the native space without keeping reference to the object
2.it delays the destruction of objects (including PJSUA2 objects), causing the code in object’s destructor to be executed out of order
3.the destruction operation by GC may run on different thread not previously registered to PJLIB, causing assertion
我们原先的消息发送是先添加好友,然后发送消息的时候直接选择好友,如下:
初始化好友:
publi