PJSUA2 Python脚本无法接听来电,自动返回603拒绝
PJSUA2 Python脚本无法接听来电,返回603 Decline问题求助
我使用PJSUA2 Python脚本无法接听来电,已尽可能简化脚本(基于官方helloworld示例及来电接收文档),拨打关联号码时呼叫立即失败并返回603 Decline。我已排除GC(持久化PJSua对象)、音频设备(使用setNullDev())、NAT(部署在Vultr直连IPv4服务器)等常见问题,部署环境为Ubuntu 22.04,以下是我的脚本及部署脚本,恳请技术支持。
Python脚本
import pjsua2 as pj import time class MyAccount(pj.Account): def onRegState(self, prm): print("***OnRegState: " + prm.reason) def onIncomingCall(self, iprm): call = MyCall(self, iprm.callId) prm = pj.CallOpParam() prm.statusCode = 200 call.answer(prm) class MyCall(pj.Call): def __init__(self, account, call_id): pj.Call.__init__(self, account, call_id) def pjsua2_test(): # Create and initialize the library ep_cfg = pj.EpConfig() ep = pj.Endpoint() ep.libCreate() ep.libInit(ep_cfg) ep.audDevManager().setNullDev() # Create SIP transport. Error handling sample is shown sipTpConfig = pj.TransportConfig() sipTpConfig.port = 5060 ep.transportCreate(pj.PJSIP_TRANSPORT_UDP, sipTpConfig) # Start the library ep.libStart() # Account configuration acfg = pj.AccountConfig() acfg.idUri = "sip:test@sip.pjsip.org"; acfg.regConfig.registrarUri = "sip:sip.pjsip.org"; cred = pj.AuthCredInfo("digest", "*", "test", 0, "pwtest"); acfg.sipConfig.authCreds.append( cred ); acfg.sipConfig.authCreds.append(cred) # Create the account acc = MyAccount() acc.create(acfg) return ep, acc # Return the endpoint to keep it alive if __name__ == "__main__": ep, acc = pjsua2_test() try: while True: time.sleep(1) except KeyboardInterrupt: print("Exiting...") finally: ep.libDestroy()
部署脚本
apt-get update && apt-get install -y build-essential libssl-dev libasound2-dev wget python3 python3-dev automake autoconf libtool libpcre2-dev bison && apt install -y python3-setuptools && cd /usr/src && wget https://github.com/swig/swig/archive/refs/tags/v4.2.1.tar.gz && tar -xvf v4.2.1.tar.gz && cd swig-4.2.1 && ./autogen.sh && ./configure && make && make install && cd /usr/src && wget https://github.com/pjsip/pjproject/archive/refs/tags/2.14.1.tar.gz && tar -xvf 2.14.1.tar.gz && cd pjproject* && ./configure CFLAGS="-fPIC" && make dep && make && make install && cd /usr/src/pjproject*/pjsip-apps/src/swig/python && make && make install && python3 setup.py install
内容的提问来源于stack exchange,提问作者Rick
相关产品推荐
相关产品推荐

