Outgoing SIP call fails.

huangapple go评论91阅读模式
英文:

Outgoing SIP call fails

问题

我正在尝试通过Python使用AMI发起呼叫。我用以下代码发起呼叫:

import socket

ami_host = 'localhost'
ami_port = 5038
ami_username = 'user'
ami_password = 'pass'
destination_number = 'dest_nubmber'
caller_id = 'caller_id'

def connect_to_ami():
    # ...(略)
    return ami_socket

def make_outgoing_call(destination, caller_id):
    ami_socket.send(f'Action: Originate\r\nChannel: SIP/sipus/{destination}\r\nExten: {destination}\r\nContext: from-internal\r\nCallerID: {caller_id}\r\nAsync: true\r\n\r\n'.encode('utf-8'))
    # ...(略)

def close_ami_connection():
    ami_socket.send('Action: Logoff\r\n\r\n'.encode('utf-8'))
    ami_socket.close()

ami_socket = connect_to_ami()
make_outgoing_call(destination_number, caller_id)
close_ami_connection()

Asterisk日志中出现错误:

WARNING[3907] channel.c: No channel type registered for 'SIP'
英文:

I am trying to initiate a call using Python through the AMI. Code I am using to initiate call:

import socket

ami_host = 'localhost'
ami_port = 5038
ami_username = 'user'
ami_password = 'pass'
destination_number = 'dest_nubmber'
caller_id = 'caller_id'


def connect_to_ami():
    ami_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    ami_socket.connect((ami_host, ami_port))
    response = ami_socket.recv(4096).decode('utf-8')
    print(response)

    ami_socket.send(f'Action: Login\r\nUsername: {ami_username}\r\nSecret: {ami_password}\r\n\r\n'.encode('utf-8'))
    response = ami_socket.recv(4096).decode('utf-8')
    print(response)

    return ami_socket


def make_outgoing_call(destination, caller_id):
    ami_socket.send(f'Action: Originate\r\nChannel: SIP/sipus/{destination}\r\nExten: {destination}\r\nContext: from-internal\r\nCallerID: {caller_id}\r\nAsync: true\r\n\r\n'.encode('utf-8'))
    response = ami_socket.recv(4096).decode('utf-8')
    print(response)


def close_ami_connection():
    ami_socket.send('Action: Logoff\r\n\r\n'.encode('utf-8'))
    ami_socket.close()


ami_socket = connect_to_ami()
make_outgoing_call(destination_number, caller_id)
close_ami_connection()

The python code runs successfully but I am getting this error in the Asterisk logs:

WARNING[3907] channel.c: No channel type registered for 'SIP'

答案1

得分: 0

这是一个Asterisk的“错误”(或消息),意味着SIP通道驱动程序未加载。

如果您可以访问Asterisk终端,请尝试执行以下命令

localhost*CLI> core show channeltypes

并检查是否有SIP,就像这个图片所示

Outgoing SIP call fails.

如果列表中没有SIP,请检查是否有PJSIP,在这种情况下,您必须更改您的代码以使用它,就像这样

ami_socket.send(f'Action: Originate\r\nChannel: PJSIP/sipus/{destination}\r\nExten: {destination}\r\nContext: from-internal\r\nCallerID: {caller_id}\r\nAsync: true\r\n\r\n'.encode('utf-8'))

如果没有加载任何SIP驱动程序,请尝试在Asterisk CLI上执行以下操作:

localhost*CLI> module load chan_sip.so

localhost*CLI> module load chan_pjsip.so

要使其永久生效,您需要修改/etc/asterisk/modules.conf文件,请查看这个链接以查看选项。

我更喜欢使用chan_sip,它更容易配置,但pjsip是下一代SIP驱动程序。

英文:

That is an Asterisk 'error' (or message), meaning that the SIP channel driver its not loaded.

if you have access to Asterisk terminal, try to execute this command

localhost*CLI> core show channeltypes

and check if you have SIP, just like this image show

Outgoing SIP call fails.

if you don't have SIP on list, check if you have PJSIP, in that case you must change your code to use it, like

ami_socket.send(f'Action: Originate\r\nChannel: PJSIP/sipus/{destination}\r\nExten: {destination}\r\nContext: from-internal\r\nCallerID: {caller_id}\r\nAsync: true\r\n\r\n'.encode('utf-8'))

If none of the SIP driver is loaded, try executing on Asterisk CLI this:

localhost*CLI> module load chan_sip.so

or

localhost*CLI> module load chan_pjsip.so

to make it permanent, you need to modify the /etc/asterisk/modules.conf file, check this link to see options

I prefer to use chan_sip, it's more ease to config, but pjsip is the next SIP generation driver

huangapple
  • 本文由 发表于 2023年6月5日 08:04:20
  • 转载请务必保留本文链接:https://go.coder-hub.com/76402890.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定