サーバにAsteriskをセットアップしました。私が持っているUDPの代わりにTCPを使用するHello Worldアスタリスクの例を変更するにはどうすればよいですか?
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
[6001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6001
aors=6001
[6001]
type=auth
auth_type=userpass
password=unsecurepassword
username=6001
[6001]
type=aor
max_contacts=1
:として
[from-internal]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()
と私のpjsip.conf
ファイル: は、私は私のextensions.conf
ファイルを持つ伴い(ドキュメントhereから直接)基本の "Hello、World" の例を設定しましたシンプルなPythonスクリプトを使用して、内線番号100への呼び出しを行います。これはdocs hereから直接呼びます。このスクリプトは、sipアドレスで渡します。sip:[email protected]<my-sip-server-ip>
:
import sys
import pjsua as pj
# Logging callback
def log_cb(level, str, len):
print str,
# Callback to receive events from Call
class MyCallCallback(pj.CallCallback):
def __init__(self, call=None):
pj.CallCallback.__init__(self, call)
# Notification when call state has changed
def on_state(self):
print "Call is ", self.call.info().state_text,
print "last code =", self.call.info().last_code,
print "(" + self.call.info().last_reason + ")"
# Notification when call's media state has changed.
def on_media_state(self):
global lib
if self.call.info().media_state == pj.MediaState.ACTIVE:
# Connect the call to sound device
call_slot = self.call.info().conf_slot
lib.conf_connect(call_slot, 0)
lib.conf_connect(0, call_slot)
print "Hello world, I can talk!"
# Check command line argument
if len(sys.argv) != 2:
print "Usage: simplecall.py <dst-URI>"
sys.exit(1)
try:
# Create library instance
lib = pj.Lib()
# Init library with default config
lib.init(log_cfg = pj.LogConfig(level=3, callback=log_cb))
# Create UDP transport which listens to any available port
transport = lib.create_transport(pj.TransportType.UDP)
# Start the library
lib.start()
# Create local/user-less account
acc = lib.create_account_for_transport(transport)
# Make call
call = acc.make_call(sys.argv[1], MyCallCallback())
# Wait for ENTER before quitting
print "Press <ENTER> to quit"
input = sys.stdin.readline().rstrip("\r\n")
# We're done, shutdown the library
lib.destroy()
lib = None
except pj.Error, e:
print "Exception: " + str(e)
lib.destroy()
lib = None
sys.exit(1)
これはすべて正常に動作し、私はSIPサーバに電話をかけ、「Hello、World」の録音を聞きます。
この通信をTCP経由で行うには、何を変更する必要がありますか?私はPythonスクリプトに渡す私のサーバーのURIに;transport=tcp
を追加し、また変更、
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
: は、これまでのところ私は、次の部分で、TCPするプロトコルを変更することによって、私のpjsip.conf
ファイルを変更しようとしています
# Create UDP transport which listens to any available port
transport = lib.create_transport(pj.TransportType.UDP)
に交通を作成するPythonスクリプトの行は、何が起こるかというと、私は
pjsua_acc.c !...SIP registration failed, status=408 (Request Timeout)
を取得するPythonスクリプトであります
そして、私は要求を全く見ません。
リンク:https://www.linuxsysadmintutorials.com/using-sip-over-tcp-with-asterisk->多分役に立ちます – Moerwald
これは基本的なネットワークトラブルシューティングです。まず、クライアント上でパケットのトレースを行い、通信していることを確認します。次に、サーバー側のファイアウォールを確認します。 – miken32
また、これはあなたの質問の誤植かもしれませんが、あなたはトランスポートをUDPに変更していると言いますが、同じ行を再び表示してください: #利用可能なポートをリッスンするUDPトランスポートを作成してください transport = lib.create_transport (pj.TransportType.UDP) – snowcloned