InnovateAsterisk / Browser-Phone

A fully featured browser based WebRTC SIP phone for Asterisk
https://www.innovateasterisk.com
GNU Affero General Public License v3.0
517 stars 256 forks source link

Not recieve message sent in chat #572

Open arezvani opened 1 day ago

arezvani commented 1 day ago

I have this pjsip.conf:

[system]
type=system
timer_t1=500
timer_b=32000
disable_tcp_switch=yes

[global]
type=global
max_initial_qualify_time=0
keep_alive_interval=90
contact_expiration_check_interval=30
default_voicemail_extension=*97
unidentified_request_count=3
unidentified_request_period=5
unidentified_request_prune_interval=30
mwi_tps_queue_high=500
mwi_tps_queue_low=-1
mwi_disable_initial_unsolicited=yes
send_contact_status_on_update_registration=yes
message_context=textmessages

[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=2

[6002]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6002
aors=6002

[6002]
type=auth
auth_type=userpass
password=123456
username=6002

[6002]
type=aor
max_contacts=2

[transport-wss]
type=transport
protocol=wss
bind=0.0.0.0
local_net=10.10.0.9/16
local_net=10.116.0.6/20
external_media_address=185.60.136.36
external_signaling_address=186.60.136.36
allow_reload=yes

[webrtc_client]
type=aor
max_contacts=5
remove_existing=yes

[webrtc_client]
type=auth
auth_type=userpass
username=webrtc_client
password=webrtc_client ; This is a completely insecure password! Do NOT expose this
 ; system to the Internet without utilizing a better password.

[webrtc_client]
type=endpoint
aors=webrtc_client
auth=webrtc_client
dtls_auto_generate_cert=yes
webrtc=yes
context=default
disallow=all
; We need to allow more codecs.
; vp8, vp9 and h264 are video pass-through codecs.
; No special Asterisk modules are required to support them.
allow=opus,g722,ulaw,vp9,vp8,h264
; Since video conferencing makes use of the Streams functionality added in Asterisk 15
; we need to indicate the maximum number of streams allowed for audio and video.
max_audio_streams = 1
max_video_streams = 15

[webrtc-phones](!)
context=main-context
transport=transport-wss
allow=!all,opus,ulaw,alaw,vp8,vp9
webrtc=yes

[User1](webrtc-phones)
type=endpoint
callerid=”User One” <100>
auth=User1
aors=User1

[User1]
type=aor
max_contacts=3

[User1]
type=auth
auth_type=userpass
username=User1
password=1234

[User2](webrtc-phones)
type=endpoint
callerid=”User Two” <101>
auth=User2
aors=User2

[User2]
type=aor
max_contacts=3

[User2]
type=auth
auth_type=userpass
username=User2
password=1234

[User3](webrtc-phones)
type=endpoint
callerid=”User Three” <102>
auth=User3
aors=User3

[User3]
type=aor
max_contacts=3

[User3]
type=auth
auth_type=userpass
username=User3
password=1234

also have this extensions.conf

[default]
exten = video-conference,1,Confbridge(MYCONF,default_bridge,default_user,sample_user_menu)

[general]
static=yes
writeprotect=yes
priorityjumping=no
autofallthrough=no

[globals]
ATTENDED_TRANSFER_COMPLETE_SOUND=beep

[main-context]
include => from-extensions
include => subscriptions
include => textmessages
include => echo-test
include => speak-exte-nnum

[echo-test]
exten => 777,1,NoOp(FEATURE: ECHO TEST)
 same => n,Answer
 same => n,Wait(1)
 same => n,Playback(demo-echotest)
 same => n,Echo()
 same => n,Playback(demo-echodone)
 same => n,Hangup()
;END of [echo-test]

[speak-exte-nnum]
exten => 888,1,NoOp(FEATURE: SPEAK MY EXTENSION NUMBER)
 same => n,Answer
 same => n,Wait(1)
 same => n,Playback(extension)
 same => n,Wait(1)
 same => n,SayDigits(${CALLERID(num)})
 same => n,Wait(2)
 same => n,Hangup()
;END of [speak-exte-nnum]

[textmessages]
exten => 100,1,Gosub(send-text,s,1,(User1))
exten => 101,1,Gosub(send-text,s,1,(User2))
exten => 102,1,Gosub(send-text,s,1,(User3))

[subscriptions]
exten => 100,hint,PJSIP/User1
exten => 101,hint,PJSIP/User2
exten => 102,hint,PJSIP/User3

[from-extensions]
; Feature Codes:
exten => *65,1,Gosub(moh,s,1)
; Extensions
exten => 100,1,Gosub(dial-extension,s,1,(User1))
exten => 101,1,Gosub(dial-extension,s,1,(User2))
exten => 102,1,Gosub(dial-extension,s,1,(User3))

exten => e,1,Hangup()

[moh]
exten => s,1,NoOp(Music On Hold)
exten => s,n,Ringing()
exten => s,n,Wait(2)
exten => s,n,Answer()
exten => s,n,Wait(1)
exten => s,n,MusicOnHold()

[dial-extension]
exten => s,1,NoOp(Calling: ${ARG1})
exten => s,n,Set(JITTERBUFFER(adaptive)=default)
exten => s,n,Dial(PJSIP/${ARG1},30)
exten => s,n,Hangup()

exten => e,1,Hangup()

[send-text]
exten => s,1,NoOp(Sending Text To: ${ARG1})
exten => s,n,Set(PEER=${CUT(CUT(CUT(MESSAGE(from),@,1),<,2),:,2)})
exten => s,n,Set(FROM=${SHELL(asterisk -rx ‘pjsip show endpoint ${PEER}’ | grep ‘callerid ‘ | cut -d’:’ -f2- | sed ‘s/^ *//’ | tr -d ‘‘)})
exten => s,n,Set(CALLERID_NUM=${CUT(CUT(FROM,>,1),<,2)})
exten => s,n,Set(FROM_SIP=${STRREPLACE(MESSAGE(from),
exten => s,n,MessageSend(pjsip:${ARG1},${FROM_SIP})
exten => s,n,Hangup()

When I send a message in chat other user don't recieve that and get this error:

    -- Executing [101@main-context:1] Gosub("Message/ast_msg_queue", "dial-extension,s,1,(User2)") in new stack
    -- Executing [s@dial-extension:1] NoOp("Message/ast_msg_queue", "Calling: User2") in new stack
    -- Executing [s@dial-extension:2] Set("Message/ast_msg_queue", "JITTERBUFFER(adaptive)=default") in new stack
    -- Executing [s@dial-extension:3] Dial("Message/ast_msg_queue", "PJSIP/User2,30") in new stack
    -- Called PJSIP/User2
[Dec  2 22:07:22] ERROR[759998][C-00000001]: translate.c:1419 ast_translator_best_choice: Cannot determine best translation path since one capability supports no formats
[Dec  2 22:07:22] WARNING[759998][C-00000001]: channel.c:6697 ast_channel_make_compatible_helper: No path to translate from PJSIP/User2-00000000 to Message/ast_msg_queue
  == Spawn extension (dial-extension, s, 3) exited non-zero on 'Message/ast_msg_queue'

what should I do?

InnovateAsterisk commented 1 day ago

Based on the log you provide, somehow its dialing the message context

-- Executing [s@dial-extension:3] Dial("Message/ast_msg_queue", "PJSIP/User2,30") in new stack

Looks like main-context includes message context, so call are able to follow it. But the message context only needs to be applied to the extension config.

This may work

[webrtc-phones](!)
context=main-context
message_context=textmessages
transport=transport-wss
allow=!all,opus,ulaw,alaw,vp8,vp9
webrtc=yes

But then take textmessages out of the includes for main-context.

arezvani commented 1 day ago

Thank you. With this change error has been changed. First I change extentions.conf to:

[send-text]
exten => s,1,NoOp(SMS receiving dialplan invoked)
exten => s,n,NoOp(To ${MESSAGE(to)})
exten => s,n,Set(TO=${MESSAGE(to)})
exten => s,n,NoOp(From ${MESSAGE(from)})
exten => s,n,NoOp(Body ${MESSAGE(body)})
exten => s,n,Set(ACTUALTO=${CUT(MESSAGE(to),@,1)})
exten => s,n,MessageSend(${ACTUALTO},${MESSAGE(from)})
exten => s,n,NoOp(Send status is ${MESSAGE_SEND_STATUS})
exten => s,n,Hangup()

Now I get this error:

    -- Executing [100@textmessages:1] Gosub("Message/ast_msg_queue", "send-text,s,1,(User1)") in new stack
    -- Executing [s@send-text:1] NoOp("Message/ast_msg_queue", "SMS receiving dialplan invoked") in new stack
    -- Executing [s@send-text:2] NoOp("Message/ast_msg_queue", "To pjsip:100@185.60.136.36") in new stack
    -- Executing [s@send-text:3] Set("Message/ast_msg_queue", "TO=pjsip:100@185.60.136.36") in new stack
    -- Executing [s@send-text:4] NoOp("Message/ast_msg_queue", "From "User2" <sip:User2@185.60.136.36>") in new stack
    -- Executing [s@send-text:5] NoOp("Message/ast_msg_queue", "Body Thjryc") in new stack
    -- Executing [s@send-text:6] Set("Message/ast_msg_queue", "ACTUALTO=pjsip:100") in new stack
    -- Executing [s@send-text:7] MessageSend("Message/ast_msg_queue", "pjsip:100,"User2" <sip:User2@185.60.136.36>") in new stack
[Dec  3 21:25:58] ERROR[1074603]: res_pjsip_messaging.c:621 msg_send: PJSIP MESSAGE - Could not find endpoint '100' and no default outbound endpoint configured

If I hardcode pjsip:User1 instead ${ACTUALTO}, I get this error:

    -- Executing [s@send-text:7] MessageSend("Message/ast_msg_queue", "pjsip:100@185.60.136.36,"User2" <sip:User2@185.60.136.36>") in new stack
[Dec  3 21:20:04] ERROR[1071222]: res_pjsip_messaging.c:621 msg_send: PJSIP MESSAGE - Could not find endpoint '100@185.60.136.36' and no default outbound endpoint configured

Can you help me to solve this problem?