Python pjsua.error,error=地址已在使用中

Python pjsua.error,error=地址已在使用中,python,pjsip,telephony,Python,Pjsip,Telephony,我试图在python中使用PJSIP模块进行调用。对于SIP传输的设置,我的做法如下 trans_cfg = pj.TransportConfig() # port for VoIP communication trans_cfg.port = 5060 # local system address trans_cfg.bound_addr = inputs.client_addr transport = lib.create_transport(pj.TransportType.UDP,tra

我试图在python中使用PJSIP模块进行调用。对于SIP传输的设置,我的做法如下

trans_cfg = pj.TransportConfig()
# port for VoIP communication
trans_cfg.port = 5060
# local system address
trans_cfg.bound_addr = inputs.client_addr
transport = lib.create_transport(pj.TransportType.UDP,trans_cfg)
$sudo lsof -t -i:5060
>> 1137
$sudo kill 1137
当我完成呼叫时,我正在清除传输设置,传输=无

我可以通过运行我的程序来调用用户。但每次我单独重启电脑时,在运行python程序时都会出现一个错误

File "pjsuatrail_all.py", line 225, in <module>
   main()
File "pjsuatrail_all.py", line 169, in main
   transport = transport_setup()
File "pjsuatrail_all.py", line 54, in transport_setup
   transport = lib.create_transport(pj.TransportType.UDP,trans_cfg)
File "/usr/local/lib/python2.7/dist-packages/pjsua.py", line 2304, in 
   create_transport
   self._err_check("create_transport()", self, err)
File "/usr/local/lib/python2.7/dist-packages/pjsua.py", line 2723, in _err_check
   raise Error(op_name, obj, err_code, err_msg)
pjsua.Error: Object: Lib, operation=create_transport(), error=Address already in use
Exception AttributeError: "'NoneType' object has no attribute 'destroy'" in <bound method Lib.__del__ of <pjsua.Lib instance at 0x7f8a4bbb6170>> ignored
然后我运行我的代码,它工作得很好。 从错误的实例来看,我可以理解,在某些地方我没有正确地关闭传输配置。在这方面谁能帮忙。

从您提供的输入可以理解,这不是pjsip包装器的问题。传输配置看起来不错

查看“create_transport”错误,程序无法创建连接,因为5060端口已被其他程序占用

因此,您正在终止该进程,并且可以运行该程序而不会出现任何错误。您只在重新启动时才这么说,因此在系统重新启动时,某些程序正在占用端口

你可以这样试试

sudo netstat -nlp|grep 5060
在你的情况下,它会像

1137/程序名


转到启动配置中的“ProgramName”,并进行修改,使其不会拾取端口

命令输出为“1147/星号”,我该怎么做?你的意思是星号服务器正在阻塞?你需要远程连接,或者你的电脑是星号服务器?我正在从我的电脑连接到远程服务器。星号服务器正在占用端口,我猜你的电脑是服务器,但我不明白您创建传输的目的是什么?那么可能是您已配置在重新启动PC时必须启动服务器。请检查配置。