I'm trying to play Music file ( MOH ) instead of ringing sound.
It's my extention_custom.conf
[from-internal]
exten = _X.,1,Verbose(call from: ${CALLERID(num)} to ${EXTEN})
same = n,Dial(Local/${CALLERID(num)}#somewhere,100,g|m(tt))
and i defined MOH class in the musiconhold_custom.conf:
[tt]
mode=files
directory=/var/lib/asterisk/moh/tt/
sort=alpha
sometimes it works and i can hear music instead of ringtone, but sometimes it's silent.
sip_custom.conf
[*****]
type=friend
secret=***
context=from-internal
username=****
host=***.***.***.***
allow=all
directmedia=yes
nat=yes
i don't know it's useful or not but when i checked the pCap files, everything in both situation were same, but when i could hear music, there is an additional line, it's :
SSRC changed from 0xC8F2189B/6305 to 0x1BEA4D36/8
Try changing directmedia to no. SSRC changing likely indicates that RTP media is being handed off from asterisk to the endpoint. If you disallow directmedia, then asterisk will stay in the middle (between the endpoints), and can always play moh.
Keep in mind this may have topology implications for your network, but assuming your endpoints are all on the same LAN with asterisk, and your asterisk server can handle the RTP traffic, you won't see much change.
i Solved this problem by adding raw ringtone at the first of my code
[from-internal]
exten = _X.,1,Verbose(call from: ${CALLERID(num)} to ${EXTEN})
same = n,Dial(Local/${CALLERID(num)}#somewhere,100,g|m(tt))
same = n,Ringing()
same = n,Wait(3)
Related
I installed Asterisk 13 on Debian 9, and I tried in several different ways to play an audio file and I call, asterisk answers but it doesn't play the file. Here is my extensions.conf:
[ivr1]
exten => s,1,NoOp(IVR1)
same => n,Answer
same => n,Read(/var/lib/asterisk/sounds/custom/welcome)
same => n,WaitExten(5)
exten => 6598,1,Goto(ivr1,s,1)
Asterisk shows:
-- Executing [6598#ivr1:1] Goto("SIP/user-cc-0000001c", "ivr1,s,1") in new stack
-- Goto (ivr1,s,1)
-- Executing [s#ivr1:1] NoOp("SIP/user-cc-0000001c", "IVR1") in new stack
-- Executing [s#ivr1:2] Answer("SIP/user-cc-0000001c", "") in new stack
-- Executing [s#ivr1:3] Read("SIP/user-cc-0000001c", "/var/lib/asterisk/sounds/custom/welcome") in new stack
-- User disconnected
I tried with 2 different SIP Clients and the sounds doesn't play. I tried with different codecs and still doesn't play.
Any ideas what could it be the problem?
Thanks
You should open rtp ports(default 10000-20000) in your firewall.
Also need ensure you have correct nat settings for your network type.
It seems you are using read function in a wrong way, it has to be something like this.
read(variable_name,sound_file)
please check link for further information
https://wiki.asterisk.org/wiki/display/AST/The+Read+Application
You should run a pcap at your client and on the asterisk server. Use wireshark to perform the capture. You should see signalling for the call setup and then the associate RTP. If you see RTP sent by asterisk and not received at your client then you have a firewall issue. You should be able to see the SDP in the SIP signalling to determine what ports are being requested by the client and asterisk. Compare that with your firewall settings. Generally speaking if your client is behind a NAT then you will need to make sure that comedia is enabled in asterisk (nat settings). You will also want to make sure to disable SIP ALG on your client-side firewall too.
This could be a NAT issue, so open your sip.conf and add the following on your peers
nat=yes ;for older asterisks versions
or
nat=force_rport,comedia ;for newer versions of asterisk
then on your CLI run sip reload
I'm using a cloud-based Asterisk server as my PBX. At my current location, the Internet is rather shaky, but cell phones are reliable and commonplace. However, international cell calls are expensive, VOIP calls are much cheaper.
So, I came up with a script in Asterisk which dials my local cell phone:
exten => _abcd.,1,NoOp(-- Making outbound call to number ${EXTEN:4} --)
same => n,Answer()
same => n,Wait(1)
same => n,Originate(SIP/+86[my_cell_no]#[voip_provider],exten,incoming_remote,##${EXTEN:4})
same => n,Hangup()
Let's say I want to call a UK mobile number, +4477something. I would use my softphone to dial abcd+4477something. The script above runs, makes a call into my local cell phone. As soon as I answer, it jumps into another extension _##. which dials the outbound number, and connects the two together.
It works perfectly. However, whilst I'm waiting for the local cell to connect, I've got silence on the line. I'd quite like to play music... but I can't use the MusicOnHold() application, because it just sits there & does nothing until I hang up!
I can't add any "DIAL" style commands (i.e. "m") to the Originate command because it doesn't support them.
Is there any known way of playing (one of) the MusicOnHold channels asynchronously whilst the rest of my dialplan gets on with it?
Would the AGI command SET MUSIC do what I wanted?
e.g.
exten => _abcd.,1,NoOp(-- Making outbound call to number ${EXTEN:4} --)
same => n,AGI(turn_music_on.sh)
same => n,Answer()
.....etc.
I'm using Asterisk 1.8, if a newer version fixes/changes the MusicOnHold behaviour, then that will be the accepted answer (but the documentation seems to suggest it's the same).
You can call to Local channel(dialplan). After that in dialplan you can use m of dial command.
https://www.voip-info.org/wiki/view/Asterisk+local+channels
same => n,Originate(Local/[my_cell_no]#out/n,exten,incoming_remote,##${EXTEN:4})
[out]
exten => _X.,1,Dial(SIP/+86${EXTEN}#[voip_provider],,m)
I am writing a simple asterisk extension plan, In which when user calls, User press key and that key store to a text file.
For this i write this extension:-
exten => 203,1,Answer()
exten => 203,2,Read(NUMBER1||1)
exten => 203,3,System(echo 'User entered ${NUMBER1}' >> /tmp/key.txt)
exten => 203,4,Hangup()
But whenever i call and press any key, file only have 'User entered', Means i am not getting key.
What i am doing wrong here?
Here is my sip.conf for extension:-
[mysjphone]
type=friend
host=dynamic
username=mysjphone
secret=blablabla
allow=gsm
dtmfmode = rfc2833
host = dynamic
Note: I am doing this in windows server (astriskwin32).
That package is built on an extremely old version of Asterisk, 1.2.x. Since that time, there were many, many improvements made to Asterisk's ability to detect and process RFC2833 DTMF events. You'll likely want to upgrade to a much newer version of Asterisk. For more information about Asterisk versions, please see:
https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions
I'm a newbie in Asterisk, so I'm gonna start with something simple.
I read some documentation and I've managed to do some basic config.
My Asterisk version is 1.6.2.9-2+squeeze10 (installed on Debian using apt-get) and changed ONLY sip.conf and extensions.conf.
My idea is to use it as a SIP client, connected to the Flowroute SIP server - but please see what's happening when I use console dial EXTEN...
sip.conf
[general]
register => 74770000:HIDDEN#sip.flowroute.com/s
registertimeout=20
context=default
allowoverlap=no
bindport=5060
bindaddr=0.0.0.0
srvlookup=no
subscribecontext=from-sip
[flowroute]
canreinvite=no
username=74770000
fromuser=74770000
secret=HIDDEN
context=default
type=friend
fromdomain=sip.flowroute.com
host=85.17.214.222
dtmfmode=rfc2833
disallow=all
allow=alaw
allow=ulaw
nat=yes
insecure=very
extensions.conf
[default]
exten => _XXXXXXXXXXXXXX,1,Dial(SIP/flowroute/${EXTEN})
;exten => _XXXXXXXXXXXXXX,2,Hangup
sip show users
loreen*CLI> sip show users
Username Secret Accountcode Def.Context ACL NAT
flowroute HIDDEN default No Always
sip show peers
loreen*CLI> sip show peers
Name/username Host Dyn Nat ACL Port Status
flowroute/74771200 85.17.214.227 N 5060 Unmonitored
1 sip peers [Monitored: 1 online, 0 offline Unmonitored: 0 online, 0 offline]
console dial EXTEN
loreen*CLI> console dial 00359891505054
[Jun 14 16:44:27] WARNING[14031]: chan_oss.c:486 setformat: Unable to re-open DSP device /dev/dsp: No such file or directory
[Jun 14 16:44:28] NOTICE[14031]: console_video.c:133 console_video_start: voice only, console video support not present
[Jun 14 16:44:28] WARNING[14033]: app_dial.c:1714 dial_exec_full: Skipping dialing interface 'SIP/flowroute/00359891505054' again since it has already been dialed
Unfortunately, Asterisk 1.6.2 was made end-of-life in april 2012, and it doesn't seem this feature is still supported, and using a sound card with Asterisk isn't the most common use-case.
Installing Asterisk from source is rather easy, and also rather clean (make uninstall will sufficiently clean it out). I highly recommend it, as it allows you to stay ahead of the game (with security and feature releases). Try it with ./configure and then make menuselect (you'll need ncurses libraries) for a really nice build interface.
While trying to test dial outbound calls on your SIP trunk (to test it's connectivity), I would recommend using the channel originate function at the CLI.
For help:
asterisk*CLI> core show help channel originate
A specific device and parameter string using your setup:
asterisk*CLI> channel originate SIP/flowroute/00359891505054 application Playback tt-monkeys
Note: This will play the sound of screaming monkeys to the called party!
Also -- if you're a smart phone user, it's rather convenient to have a softphone hooked up as an extension to test your trunks, new dialplans, etc. (Although I'll always do my initial tests with channel originate)
Lastly -- but equally importantly... I realize this is a test scenario, but... As you bring this forward; I'd avoid directly dialing your ITSP with the dialed extension from the [default] context. This could, if not otherwise configured properly, leave you open to toll-fraud via the fact that asterisk defaults call attempts to this context if the context is otherwise unknown.
We are running asterisk with 8 port FXO. FXO connects to our old PBX (Samsung Office Serv 100).
Now we want to record all calls routed through FXO (if it was dialed to outside or comming from outside).
Is there a simple way to do this?
Are you running plain Asterisk? If so you can modify your dial plan to start 'monitoring' the channel, which will record the call.
The monitor command's documentation: http://www.voip-info.org/wiki/view/Asterisk+cmd+monitor
Just for the sake of completion, here's the documentation:
[root#localhost ~]# asterisk -rx 'core show application monitor'
-= Info about application 'Monitor' =-
[Synopsis]
Monitor a channel
[Description]
Monitor([file_format[:urlbase],[fname_base],[options]]):
Used to start monitoring a channel. The channel's input and output
voice packets are logged to files until the channel hangs up or
monitoring is stopped by the StopMonitor application.
file_format optional, if not set, defaults to "wav"
fname_base if set, changes the filename used to the one specified.
options:
m - when the recording ends mix the two leg files into one and
delete the two leg files. If the variable MONITOR_EXEC is set, the
application referenced in it will be executed instead of
soxmix and the raw leg files will NOT be deleted automatically.
soxmix or MONITOR_EXEC is handed 3 arguments, the two leg files
and a target mixed file name which is the same as the leg file names
only without the in/out designator.
If MONITOR_EXEC_ARGS is set, the contents will be passed on as
additional arguments to MONITOR_EXEC
Both MONITOR_EXEC and the Mix flag can be set from the
administrator interface
b - Don't begin recording unless a call is bridged to another channel
i - Skip recording of input stream (disables m option)
o - Skip recording of output stream (disables m option)
By default, files are stored to /var/spool/asterisk/monitor/.
Returns -1 if monitor files can't be opened or if the channel is already
monitored, otherwise 0.
And here's a sample way you can use it:
; This fake context records all outgoing calls to /var/spool/asterisk/monitor in wav format.
[fake-outgoing-context]
exten => s,1,Answer()
exten => s,n,Monitor(wav,,b)
exten => s,n,Dial(DAHDI/g0/${EXTEN})
exten => s,n,Hangup()
Obviously you'd have to make changes to my code, but hopefully that gives you a good idea.
A real life example is
exten => _87X,1,NoOp()
exten => _87X,n,MixMonitor(${UNIQUEID}.wav,ab)
exten => _87X,n,Dial(SIP/${EXTEN},45)
exten => _87X,n,StopMixMonitor()
exten => _87X,n,Hangup()
It's good practise to always have NoOp - the first rule must start with 1, this way you can interchange the rules with the n step any way you want.
It's always best to use MixMonitor as opposed to Monitor - Monitor only records inbound or outbound audio - MixMonitor uses both.
Also wav is quite a good choice as a format - I also use a script to transform the wav files to OGG at the end of the day - the best compromise between size / quality and licensing issues.
With regards to the arguments
a is append
b is bridge (good for production - it will only record when the call is answered - not good for debugging)
With regards to StopMixMonitor(), I'm just being thorough, but for examples there are cases in which you would like to stop the recording, for example:
...
exten => _39[5-9],n,Dial(SIP/${EXTEN},45)
exten => _39[5-9],n,GotoIf($["${DIALSTATUS}" = "BUSY"]?busy:unavailable)
exten => _39[5-9],n(busy),NoOp()
exten => _39[5-9],n,StopMixMonitor()
exten => _39[5-9],n,Voicemail(${EXTEN},u)
exten => _39[5-9],n,Hangup()
exten => _39[5-9],n(unavailble),NoOp()
exten => _39[5-9],n,StopMixMonitor()
exten => _39[5-9],n,Hangup()
...
In this example, you would stop the recording of the voice mail interaction.
Hope this will bring some light on the matter.
Depending on the specifications of your Asterisk box you might find this hack useful too. Create a rather large ramdisk and mount /var/spool/asterisk/monitor to it. That way Asterisk records to memory not disk. Then write a script under cron to move the recordings to permanent storage every 15-30 minutes or so.