How do I route call to an Asterisk server

Hi guys,

My sip.conf file is ->>>

[forward_call]
type=peer
insecure=port
nat=no
canreinvite=no
host=219.53.192.172
context=verifyout
disallow=all
allow=ulaw
allow=g729
dtmfmode=rfc2833

I am trying to route the call to the host IP address but it is not hitting the IP address cos I can still hear my IVR and not the host IVR

Show us your dialplan and Asterisk CLI output when attempting a call.
–Satish Barot

exten => calldirectdialing,1,NoOp(destination = ${destination}, user_id = ${user_id}, gateway = ${gateway})
same => n,Dial(SIP/${destination}@forward_${gateway},20,m)
same => n,Playback(/var/lib/asterisk/sounds/en/vm-nobodyavail)
same => n,Hangup()

CLI>

-- Executing [15672440000@callingout:1] NoOp("SIP/198.101.50.4-00000288", "") in new stack
-- Executing [15672440000@callingout:2] Playback("SIP/198.101.50.4-00000288", "/var/lib/asterisk/sounds/en/system-processing") in new stack
-- <SIP/198.101.50.4-00000288> Playing '/var/lib/asterisk/sounds/en/system-processing.slin' (language 'en')
-- Executing [15672440000@callingout:3] Set("SIP/198.101.50.4-00000288", "__DidNumber=15672440000") in new stack
-- Executing [15672440000@callingout:4] Set("SIP/198.101.50.4-00000288", "__mode=DIRECT-DIALING") in new stack
-- Executing [15672440000@callingout:5] Set("SIP/198.101.50.4-00000288", "count=1") in new stack
-- Executing [15672440000@callingout:6] GotoIf("SIP/198.101.50.4-00000288", "1?modecheck,1:cancel,1") in new stack
-- Goto (callingout,modecheck,1)
-- Executing [modecheck@callingout:1] NoOp("SIP/198.101.50.4-00000288", "") in new stack
-- Executing [modecheck@callingout:2] Playback("SIP/198.101.50.4-00000288", "/var/lib/asterisk/sounds/en/system-processing") in new stack
-- <SIP/198.101.50.4-00000288> Playing '/var/lib/asterisk/sounds/en/system-processing.slin' (language 'en')
-- Executing [modecheck@callingout:3] GotoIf("SIP/198.101.50.4-00000288", "1?continue,directdialing,1:continue,pindialing,1") in new stack
-- Goto (continue,directdialing,1)
-- Executing [directdialing@continue:1] NoOp("SIP/198.101.50.4-00000288", "DidNumber = 15672440000") in new stack
-- Executing [directdialing@continue:2] Set("SIP/198.101.50.4-00000288", "ARRAY(__user_id,__destination,__gateway)=24,30171942,call") in new stack
-- Executing [directdialing@continue:3] Set("SIP/198.101.50.4-00000288", "CALLS_UPDATE(24, 15672440000, 30171942, call)") in new stack

[Aug 25 14:18:44] WARNING[8222][C-000060b5]: pbx_variables.c:1096 pbx_builtin_setvar: Set requires an ‘=’ to be a valid assignment.
– Executing [directdialing@continue:4] Goto(“SIP/198.101.50.4-00000288”, “forward,calldirectdialing,1”) in new stack
– Goto (forward,calldirectdialing,1)
– Executing [calldirectdialing@forward:1] NoOp(“SIP/198.101.50.4-00000288”, “destination = 30171942, user_id = 24, gateway = call”) in new stack
– Executing [calldirectdialing@forward:2] Dial(“SIP/198.101.50.4-00000288”, “SIP/30171942@forward_call,20,m”) in new stack
== Using SIP RTP CoS mark 5
– Called SIP/30171942@forward_call
– Started music on hold, class ‘default’, on channel ‘SIP/198.101.50.4-00000288’
– SIP/forward_call-00000289 is ringing
– SIP/forward_call-00000289 answered SIP/198.101.50.4-00000288
– Stopped music on hold on SIP/198.101.50.4-00000288
– Channel SIP/forward_call-00000289 joined ‘simple_bridge’ basic-bridge
– Channel SIP/198.101.50.4-00000288 joined ‘simple_bridge’ basic-bridge
– Channel SIP/198.101.50.4-00000288 left ‘simple_bridge’ basic-bridge
== Spawn extension (forward, calldirectdialing, 2) exited non-zero on ‘SIP/198.101.50.4-00000288’
– Channel SIP/forward_call-00000289 left ‘simple_bridge’ basic-bridge

Your logs show the call is hitting SIP device/trunk forward_call

Maybe I am misinterpreting something. I will check what IVR I’m expecting, thank you Satis.

Also Satis, I have a writesql statement in func_odbc but it is not inserting in the database.

[UPDATE]
prefix = CALLS
dsn = asterisk
writesql = INSERT INTO calls(date, user_id, source, destination, channel)
writesql += VALUES(‘2016-12-23:08:99:00’, ‘${VAL1}’, ‘${VAL2}’, ‘${VAL3}’, ‘${VAL4}’)

and in dialplan I have this

exten => directdialing,1,NoOp(DidNumber = ${DidNumber})
same => n, set(ARRAY(__user_id,__destination,__gateway)=${DESTINATION_INFO(${DidNumber})})
same => n,set(CALLS_UPDATE(${user_id}, ${DidNumber}, ${destination}, ${gateway}))
same => n,Goto(forward,calldirectdialing,1)

But is not inserting records

I see you are passing ARGs and using VALs in writesql.
Try replacing ${VALn} with ${ARGn} and see.
If it still fails then post your CLI output.

You should have created a new thread as this is a different issue than the one mentioned in subject.

Okay Satis, please what is the difference between VALs and ARG. Please enlighten me, I do not know when to use either.

When I run it again I noticed this in the CLI

CLI >

[Aug 25 16:18:57] WARNING[8670][C-000060cd]: pbx_variables.c:1096 pbx_builtin_setvar: Set requires an ‘=’ to be a valid assignment.

I think this statement is not correct

same => n,set(CALLS_UPDATE(${user_id}, ${DidNumber}, ${destination}, ${gateway}))

It is requesting for an ‘=’ sign

change
same => n,set(CALLS_UPDATE(${user_id}, ${DidNumber}, ${destination}, ${gateway}))
to
same => n,set(CALLS_UPDATE(${user_id}, ${DidNumber}, ${destination}, ${gateway})=)

and that WARNING should go away.

I think you should go through this http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/getting_funky.html

It works ut gave this warning sign

pbx_variables.c:1101 pbx_builtin_setvar: Please avoid unnecessary spaces on variables as it may lead to unexpected results (‘CALLS_UPDATE(24, 15672440000, 30171942, call)’ set to ‘’).