如何配置星号即时消息

时间:2014-04-16 11:54:37

标签: ubuntu asterisk instant-messaging

asterisk是否支持即时消息?我曾尝试为IM(from this example)配置星号,但当我尝试将IM发送到另一个sip帐户时,星号会返回警告:

WARNING[20128]: chan_sip.c:16379 receive_message: Received message to sip:test3@192.168.21.153 from sip:test1@192.168.21.153; tag=d9fdcc28313946c5a2a6ae1eae997c62, dropped it... Content-Type:text/plain Message: hahaha 此外,SIP客户端返回消息“不允许的方法”。这是我的 sip.conf 文件:

[general]
context=internal
allowguest=no
allowoverlap=no
bindport=5060
bindaddr=0.0.0.0
srvlookup=no
disallow=all
allow=ulaw
alwaysauthreject=yes
canreinvite=no
nat=yes
session-timers=refuse
localnet=192.168.21.153/255.255.255.0
accept_outofcall_message=yes
outofcall_message_context=internal

[test1]
type=friend
host=dynamic
secret=test1
context=internal

[test2]
type=friend
host=dynamic
secret=test2
context=internal

[test3]
type=friend
host=dynamic
secret=test3
context=internal

这是我的 extensions.conf 文件:

[internal]
exten => test1,1,Answer()
exten => test1,2,Dial(SIP/test1,60)
exten => test1,3,Playback(vm-nobodyavail)
exten => test1,4,VoiceMail(test1@main)
exten => test1,5,Hangup()

exten => test2,1,Answer()
exten => test2,2,Dial(SIP/test2,60)
exten => test2,3,Playback(vm-nobodyavail)
exten => test2,4,VoiceMail(test2@main)
exten => test2,5,Hangup()

exten => test3,1,Answer()
exten => test3,2,Dial(SIP/test3,60)
exten => test3,3,Playback(vm-nobodyavail)
exten => test3,4,VoiceMail(test3@main)
exten => test3,5,Hangup()

exten => 8001,1,VoicemailMain(test1@main)
exten => 8001,2,Hangup()

exten => 8002,1,VoicemailMain(test2@main)
exten => 8002,2,Hangup()

exten => 8003,1,VoicemailMain(test3@main)
exten => 8003,2,Hangup()

exten => _.,1,NoOp(SMS receiving dialplan invoked) 
exten => _.,n,NoOp(To ${MESSAGE(to)}) 
exten => _.,n,NoOp(From ${MESSAGE(from)}) 
exten => _.,n,NoOp(Body ${MESSAGE(body)}) 
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)}) 
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)}) 
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS}) 
exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]? 
sendfailedmsg) 
exten => _.,n,Hangup() 
exten => h,1,Hangup() 
; 
; Handle failed messaging 
exten => _.,n(sendfailedmsg),Set(MESSAGE(body)="[${STRFTIME(${EPOCH},, 
%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Retry later.") 
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)}) 
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)}) 
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter) 
exten => _.,n,Hangup() 
exten => h,1,Hangup() 

2 个答案:

答案 0 :(得分:8)

是。 Asterisk正在支持IM。请使用Asterisk 11或更高版本。我认为你使用的是旧版本。我在星号-10中遇到了同样的问题。我升级到Asterisk到Asterisk-11。请参阅以下Asterisk IM的详细说明。

sip.conf文件的常规部分中写下以下行。

[general]

accept_outofcall_message=yes 
outofcall_message_context=dialplan_name
auth_message_requests=yes

extensions.conf文件中写下以下行。这是用于发送IM的拨号方案。

[dialplan_name]
exten => _.,1,NoOp(SMS receiving dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
exten => _.,n,AGI(chatplan.php,${MESSAGE(from)})
;exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
;exten => _.,n,ExecIf($["${ACTUALTO}" != "sip:${EXTEN}"]?Set(ACTUALTO=sip:${EXTEN}))
exten => _.,n,MessageSend(${ACTUALTOS},${MESSAGE(from)})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
exten => _.,n,Hangup()
;
; Handle failed messaging
exten => _.,n(sendfailedmsg),NoOp(Sending error to user)
exten => _.,n,Set(SRC=${MESSAGE(from)})
exten => _.,n,Set(DST=${MESSAGE(to)})
exten => _.,n,Set(MSG=${MESSAGE(body)}) 
exten => _.,n,Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Your message to ${EXTEN} has failed. Sending when available")
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter)
exten => _.,n,GotoIf($["${INQUEUE}" != "1"]?startq)
exten => _.,n,Hangup()
;
exten => _.,n(startq),NoOp(Queueing messaging for offline)
exten => _.,n,Set(MSGTIME=${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)})
exten => _.,n,SYSTEM(/var/lib/asterisk/agi-bin/astqueue.sh –SRC ‘${SRC}’ –DST ‘${DST}’ –MSG ‘${MSG}’)
exten => _.,n,Hangup()[app-fakeanswer]
exten => _.,1,NoCDR
exten => _.,n,Set(DESTDEV=${EXTEN})
exten => _.,n,Set(THISDEVSTATE=${DEVICE_STATE(SIP/${DESTDEV})})
exten => _.,n,GotoIf($["${THISDEVSTATE}" = "UNAVAILABLE"]?hang)
exten => _.,n,GotoIf($["${THISDEVSTATE}" = "UNKNOWN"]?hang)
exten => _.,n,Answer
exten => _.,n,Hangup()
exten => _.,n(hang),Hangup()

在您尊重的文件中添加以上行。使用Asterisk-11进行IM。我在旧的星号版本中遇到了同样的问题。希望你使用的是Asterisk-11。

答案 1 :(得分:0)

将Asterisk版本13弄乱了一段时间后,将其从我的小细胞移植到另一个小细胞。这也取决于代理商进行交付。如果该应用程序或程序无法接收消息,则无所事事,您将收到以下消息:

Unable to create channel of type 'SIP' (cause 58 - Bearer capability not available)

但是,如果这些设备能够发送消息,那么您将获得确定。最好的测试方法是先在同一个设备上进行测试,然后您才能向自己发送和接收消息。一旦您在同一个细胞上获得了味精,就知道它至少在您的单位中可以正常工作,然后您可以使用相同的应用程序或程序在另一个单位中进行测试。完成此操作后,您需要尝试其他应用程序或程序和单元,然后进行调试(如果不起作用)。

[MENSAGEIRO]

exten => _.,1,NoOp(SMS receiving dialplan invoked)
exten => _.,n,NoOp(To ${MESSAGE(to)})
exten => _.,n,NoOp(From ${MESSAGE(from)})
exten => _.,n,NoOp(Body ${MESSAGE(body)})
;exten => _.,n,AGI(chatplan.php,${MESSAGE(from)})
exten => _.,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => _.,n,ExecIf($["${ACTUALTO}" != "sip:${EXTEN}"]?Set(ACTUALTO=sip:${EXTEN}))
exten => _.,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => _.,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => _.,n,GotoIf($["${MESSAGE_SEND_STATUS}" != "SUCCESS"]?sendfailedmsg)
exten => _.,n,Hangup()
;; Handle failed messaging
exten => _.,n(sendfailedmsg),NoOp(Sending error to user)
exten => _.,n,Set(SRC=${MESSAGE(from)})
exten => _.,n,Set(DST=${MESSAGE(to)})
exten => _.,n,Set(MSG=${MESSAGE(body)})
exten => _.,n,Set(MESSAGE(body)="[${STRFTIME(${EPOCH},,%d%m%Y-%H:%M:%S)}] Sua mensagem para ${EXTEN} falhou. Destinatário não está on-line")
exten => _.,n,Set(ME_1=${CUT(MESSAGE(from),<,2)})
exten => _.,n,Set(ACTUALFROM=${CUT(ME_1,@,1)})
exten => _.,n,MessageSend(${ACTUALFROM},ServiceCenter)
;exten => _.,n,GotoIf($["${INQUEUE}" != "1"]?startq)
exten => _.,n,Hangup()

您需要使用以下

在文件 extensions.conf 中添加这些行,并在文件 sip.conf user.conf 中进行引用。位于 / etc / asterisk 文件夹中的em> context 名为MENSAGEIRO。

一旦您在这里看到味精顺利通过,您就会在CLI上注意到

 NoOp("Message/ast_msg_queue", "Send status is SUCCESS") in new stack

积分https://gist.github.com/jugaso/58d76fade445521d7fc15b9c82ee7a50