首页 > 解决方案 > PJSUA 转移调用在 python37 中不起作用如何在 python27 中起作用

问题描述

current_call.transfer("sip:1001@xx.xx.xx.xx") 正在运行 python2.7 但是它在下面的 python3.7 中不起作用是错误

Original exception was:
Traceback (most recent call last):
  File "trycall.py", line 151, in <module>
    current_call.transfer("sip:1001@xx.xx.xx.xx")
  File "/usr/local/lib/python3.7/dist-packages/pjsua.py", line 1734, in transfer
    Lib._create_msg_data(hdr_list))
SystemError: <built-in function call_xfer> returned NULL without setting an error

标签: python-3.xpython-2.7pjsippjsua2

解决方案


我正在使用 PJSIP 的这个分支:Link for PJSUA implementation with Python 3.6 并且遇到了同样的传输问题。

从函数py_pjsua_call_xfer (pjproject/pjsip-apps/src/python/_pjsua.c) 中删除此检查解决了我的问题:

if (!PyBytes_Check(pDstUri))
    return NULL;

在我的所有测试中,此检查始终返回 NULL。我无法用 Python 解决这个问题。删除上面提到的代码解决了这个问题,现在它还没有产生任何新问题。我已经用 Asterisk 和 3 个 SIP 端点测试了这个修改,并且传输得到了正确处理。

(注意:我不是 C/C++ 程序员,所以我无法详细说明为什么这段代码不起作用。这种方法基于反复试验。)


推荐阅读