我正在为pjsua使用python模块,并试图注册到PBX。
以下是代码:
import sys
import pjsua as pj
import threading
def log_cb(level, str, len)
print str,
class MyAccountCallback(pj.AccountCallback)
sem = None
def __init__(self, account)
pj.AccountCallback.__init__(self, account)
def wait(self)
self.sem = threading.Semaphore(0)
self.sem.acquire()
def on_reg_state(self)
if self.sem
if self.account.info().reg_status = 200
self.sem.release()
lib = pj.Lib()
try
lib.init(log_cfg = pj.LogConfig(level=4, callback=log_cb))
lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(5060))
lib.start()
acc = lib.create_account(pj.AccountConfig("181.21.200.109:5060", "561123", "admin"))
acc_cb = MyAccountCallback(acc)
acc.set_callback(acc_cb)
acc_cb.wait()
print n
print Registration complete, status=, acc.info().reg_status,
( + acc.info().reg_reason + )
print nPress ENTER to quit
sys.stdin.readline()
lib.destroy()
lib = None
except pj.Error, e
print Exception + str(e)
lib.destroy()PBX是181.21.200.109,我试图注册的号码是123456,至于密码-我只输入了123 (我不认为PBX需要密码)。
我从PBX得到一个sip 403小口包,禁止(坏消息)。
为了进行比较,我查看了来自不同sip客户端的另一个成功注册的注册包。( PBX发送回选项包)。
这里是包:
这个包得到禁止的响应(失败)
REGISTER sip:181.21.200.109:5060 SIP/2.0
Via: SIP/2.0/UDP 181.21.200.50:51117;rport;branch=z9hG4bKPj36c48c6ff87b47ac86c9036e0acbaed4 (Different)
Route: <sip:181.21.200.109:5060;lr> (Different)
Max-Forwards: 70
From: <sip:561123@181.21.200.109>;tag=10a3290c7748480c9c0808366ae0c840 (Different)
To: <sip:561123@181.21.200.109> (Different)
Call-ID: 94f280c9cfcf41539b500ff39582a1ef
CSeq: 21606 REGISTER
User-Agent: pjsip python
Contact: <sip:561123@181.21.200.50:51117;ob> (Different)
Expires: 300
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS - (Different Options)
Authorization: Digest username="561123", realm="asterisk", nonce="21f4ad6b", uri="sip:181.21.200.109:5060", response="62a339057d2b4e3fed4d368ff94f6d46", algorithm=MD5
Content-Length: 0此数据包获得选项响应(成功)
REGISTER sip:181.21.200.109:5060 SIP/2.0
Via: SIP/2.0/UDP 181.21.200.150;rport;branch=z9hG4bK4H5Z6Z2myFUNr
Max-Forwards: 70
From: <sip:561123@181.21.200.109:5060>;tag=307m6Zy8cj7pa
To: <sip:561123@181.21.200.109:5060>
Call-ID: f3ce9234-40e3-1233-a783-5c6b32d1a9b5
CSeq: 3 REGISTER
Contact: <sip:561123@181.21.200.150>
User-Agent: sofia-sip/1.12.11
Allow: REGISTER, INVITE, ACK, BYE, CANCEL, OPTIONS, MESSAGE, SUBSCRIBE, REFER, UPDATE, INFO
Supported: timer, 100rel, path
Authorization: Digest username="561123", realm="asterisk", nonce="7625cf17", algorithm=MD5, uri="sip:181.21.200.109:5060", response="dca3173b2159f812481ca0c96b10a751"
Content-Length: 0,有人知道为什么我会得到禁止的回应吗?我的代码有问题吗?
致谢
发布于 2015-02-24 12:40:10
您的PABX 确实需要这些帐户的密码(否则我们就不会看到、响应和授权头本身),因此要确保密码是有效的。如果找不到帐户(配置: alwaysauthreject=yes),星号也可能拒绝使用403注册,而且您的日志没有说明这一点,因为您试图注册不同于python和独立客户机的扩展。
最好使用相同的扩展进行比较(但不要尝试在同一时间注册两个软件)。
https://stackoverflow.com/questions/28672233
复制相似问题