Hi, I am trying to automatically hangup calls witch return redirect codes. It works except for the end :) -> $ python ex.py sip:somebody at somewhere.org 19:42:20.622 os_core_unix.c pjlib 1.6 for POSIX initialized 19:42:20.623 sip_endpoint.c Creating endpoint instance... 19:42:20.624 pjlib select() I/O Queue created (0x81e87c0) 19:42:20.624 sip_endpoint.c Module "mod-msg-print" registered 19:42:20.624 sip_transport. Transport manager created. hanging up disco python: ../src/pjsua-lib/pjsua_call.c:1346: pjsua_call_get_user_data: Assertion `call_id>=0 && call_id<(int)pjsua_var.ua_cfg.max_calls' failed. Abort 1) How can i get rid of the debug messages? 2) Should I recompile with some less verbose settings? But more important: what is wrong with the code (see attachment)? I just copied and combined the lines from the examples. 3) Can I somehow wait in the main thread until the end of call (maybe lock)? Thanks, Karol import sys import threading import pjsua as pj class CallCallback(pj.CallCallback): def __init__(self, call=None): pj.CallCallback.__init__(self, call) def on_state(self): s = self.call.info().last_code if s >= 183: if self.call.info().state == pj.CallState.DISCONNECTED: print 'disco' try: if self.call.deleting: return except AttributeError: self.call.deleting = True print 'hanging up' self.call.hangup() class AccountCallback(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() lib.create_transport(pj.TransportType.UDP, pj.TransportConfig(5080)) lib.start() acc = lib.create_account(pj.AccountConfig('server.com', 'user', 'secret')) acc_cb = AccountCallback(acc) acc.set_callback(acc_cb) acc_cb.wait() if len(sys.argv) == 2: call = acc.make_call(sys.argv[1], CallCallback()) raw_input('press ENTER to quit') lib.destroy() except pj.Error, e: print 'exception: ' + str(e) lib.destroy()