How is the freeswitch integration with adhersion status?

32 views
Skip to first unread message

Juan Bernabó

unread,
May 1, 2008, 10:24:28 PM5/1/08
to Adhearsion
Hi,

I would like to know how people is using freeswitch with adhersion,
what uses cases are working and what is the status in general.

I really would like to start investigating adhersion for a couple of
telefony services I'm planning and it would be really nice to be able
to do those in ruby with a nice dslysh thing like adhersion.

Thanks in advance,
Juan.

Nicolas Brenner

unread,
May 2, 2008, 2:04:40 PM5/2/08
to adhea...@googlegroups.com
I'd also really like to use adhearsion with Freeswitch. Right now I
managed to get adhearsion to initialize "the freeswitch stuff", and
configuring a special section on the default Freeswitch dialplan I was
able to receive a call, but whenever I try to execute a command I get
something along the lines of:

$ ahn start .
[Fri May 2 12:32:59 2008] Starting FreeSwitch OES Server
INFO ahn: Adhearsion initialized!
[Fri May 2 12:33:03 2008] Incoming call on the FreeSwitch outbound
event socket...
[Fri May 2 12:33:03 2008] Connected to Freeswitch. Waiting for answer state.
[Fri May 2 12:33:03 2008] Loading cached dialplan
[Fri May 2 12:33:03 2008] Checking whether the contexts should be reloaded
[Fri May 2 12:33:03 2008] Getting the contexts
[Fri May 2 12:33:03 2008] Creating a new OesDispatcher
[Fri May 2 12:33:03 2008] Done creating it
[Fri May 2 12:33:03 2008] Finished loading cached dialplans
[Fri May 2 12:33:03 2008] Found context default from call variables.
#<NoMethodError: undefined method `extension' for
#<Adhearsion::VoIP::FreeSwitch::FreeSwitchDialplanCommandFactory:0xb7cc1750>>
...

I'm a ruby beginner, but if I could help in some way to make this
work, I'd really like to contribute!

--
Nicolás Brenner
Medularis SpA
website: www.medularis.com

harry

unread,
May 3, 2008, 4:40:43 AM5/3/08
to adhea...@googlegroups.com
What's the code? Seems like you are doing something like

def extension
.. do stuff ..
end

The right syntax is

extension {
.. do stuff ..
}

2008/5/2 Nicolas Brenner <nic...@medularis.com>:

Nicolas Brenner

unread,
May 3, 2008, 10:31:06 PM5/3/08
to adhea...@googlegroups.com
I tried something like the example from adhearsion.com:

default {
case extension
when 777
puts "hello"

end

Daniel Kinsley

unread,
May 15, 2008, 6:49:47 PM5/15/08
to Adhearsion
It looks like not all of the functions are implemented for the
dialplan.rb syntax.
If you create them explicitly in the FreeSwitchDialplanCommandFactory
class it will work.

I can execute any of the functions in the
FreeSwitchDialplanCommandFactory in the dialplan.rb context blocks.
Now it seems that there are functions for set, join, play, etc;
however there is no way to call someone, like a bridge function or
dial. If I write a function for bridge, like so:
def bridge(context, extension)
cmd 'bridge', 'sofia/'+context+'/'+extension
end

I can use it in dialplan.rb like:
bridge "default", "1000"

and it will dial the peer.

Now I am exteremly new to ruby so I don't know if this is a hack. I
don't know if the goal is to create a function for each command in
Freeswitch, such as bridge, join, set, transfer, etc to create all the
dialplan logic that will be used in dialplan.rb.

It seems like everything is there for Freeswitch to work, but there
are just a few things missing.

-Dan Kinsley

On May 3, 10:31 pm, "Nicolas Brenner" <nico...@medularis.com> wrote:
> I tried something like the example from adhearsion.com:
>
> default {
> case extension
> when 777
> puts "hello"
>
> end
> }
>
>
>
> On Sat, May 3, 2008 at 4:40 AM, harry <ichverst...@gmail.com> wrote:
>
> > What's the code? Seems like you are doing something like
>
> > def extension
> > .. do stuff ..
> > end
>
> > The right syntax is
>
> > extension {
> > .. do stuff ..
> > }
>
> > 2008/5/2 Nicolas Brenner <nico...@medularis.com>:
>
> > > I'd also really like to use adhearsion withFreeswitch. Right now I
> > > managed to get adhearsion to initialize "thefreeswitchstuff", and
> > > configuring a special section on the defaultFreeswitchdialplan I was
> > > able to receive a call, but whenever I try to execute a command I get
> > > something along the lines of:
>
> > > $ ahn start .
> > > [Fri May 2 12:32:59 2008] StartingFreeSwitchOES Server
> > > INFO ahn: Adhearsion initialized!
> > > [Fri May 2 12:33:03 2008] Incoming call on theFreeSwitchoutbound
> > > event socket...
> > > [Fri May 2 12:33:03 2008] Connected toFreeswitch. Waiting for answer state.
> > > [Fri May 2 12:33:03 2008] Loading cached dialplan
> > > [Fri May 2 12:33:03 2008] Checking whether the contexts should be reloaded
> > > [Fri May 2 12:33:03 2008] Getting the contexts
> > > [Fri May 2 12:33:03 2008] Creating a new OesDispatcher
> > > [Fri May 2 12:33:03 2008] Done creating it
> > > [Fri May 2 12:33:03 2008] Finished loading cached dialplans
> > > [Fri May 2 12:33:03 2008] Found context default from call variables.
> > > #<NoMethodError: undefined method `extension' for
> > > #<Adhearsion::VoIP::FreeSwitch::FreeSwitchDialplanCommandFactory:0xb7cc1750>>
> > > ...
>
> > > I'm a ruby beginner, but if I could help in some way to make this
> > > work, I'd really like to contribute!
>
> > > On Thu, May 1, 2008 at 10:24 PM, Juan Bernabó <juan.bern...@gmail.com> wrote:
>
> > > > Hi,
>
> > > > I would like to know how people is usingfreeswitchwith adhersion,

Nicolas Brenner

unread,
May 16, 2008, 9:54:16 AM5/16/08
to adhea...@googlegroups.com
That doesn't work for me. After defining the method, I get:

[Fri May 16 08:38:09 2008] Done creating it
INFO oes: Finished loading cached dialplans
INFO oes: Found context default from call variables.
method missing [bridge]
INFO oes: Not a noop. Sending bridge(sofia/sip.ipcorp.cl/005622360310)
#<NoMethodError: private method `chomp' called for nil:NilClass>
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb:23:in
`get_raw_header'
/usr/local/lib/ruby/gems/1.8/gems/activesupport-2.0.2/lib/active_support/core_ext/object/misc.rb:28:in
`returning'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb:21:in
`get_raw_header'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb:17:in
`get_header'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/freeswitch/oes_server.rb:161:in
`dispatch!'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/freeswitch/oes_server.rb:159:in
`call'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/freeswitch/oes_server.rb:159:in
`dispatch!'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb:80:in
`method_missing'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb:76:in
`map'
/usr/local/lib/ruby/gems/1.8/gems/adhearsion-0.7.999/lib/adhearsion/voip/dsl/dialplan/dispatcher.rb:76:in
`method_missing'
(eval):5:in `get_contexts'

And after I fix the chomp thing on line 23 of
adhearsion-0.7.999/lib/adhearsion/voip/freeswitch/basic_connection_manager.rb,
adding 'unless line.nil?' to the end of that line, I still get:

[Fri May 16 08:39:23 2008] Done creating it
INFO oes: Finished loading cached dialplans
INFO oes: Found context default from call variables.
method missing [bridge]
INFO oes: Not a noop. Sending bridge(sofia/sip.provider.com/xxxxxxx)

Weird thing is, I get a notice saying the method is missing, but it
still executes the method. Nonetheless, the original call is dropped,
so the bridge doesn't work.

Nico

Daniel Kinsley

unread,
May 17, 2008, 6:38:01 PM5/17/08
to Adhearsion
Nicolas,
Good call with the chomp command, I was getting the same error.

I was also having problems with the log, apparently in the
OesDispatcher server it was calling something like:
log "Not a noop. Sending #{event.app}(#{event.args.to_a * " "})"
However I changed it to
ahn_log "Not a noop. Sending #{event.app}(#{event.args.to_a * " "})"
because the log function came through inheritance of the GServer
class, however the OesDispatcher is not derived from that class. I
changed all the "log" to "ahn_log" and seems to work better.

I am not really sure why you were getting the "method missing
[bridge]", did you add that yourself in the method_missing function of
the dispatcher?

Maybe the reason your bridge isn't working is because the channel is
already answered, so its doing crazy things.

In order for me to get adhearsion working originally I needed to
answer the channel in freeswitch before I sent it off to adhearsion,
otherwise it would just hang. My dialplan looked like this:
<extension name="adhearsion">
<condition field="destination_number" expression="^(333)$">
<action application="answer"/>
<action application="socket" data="127.0.0.1:8021 full"/>
</condition>
</extension>

Now if I take out the answer command in freeswitch, and then comment
out the following lines in the oes_server.rb file,
# until answered
# answered ||= conn.get_header['Event-Name'] ==
'CHANNEL_ANSWER'
# end

It will continue to process even if the channel is not answered, and
then it will send the bridge off to your caller.

Here is the bridge function I have;
def bridge(context, extension)
puts "i'm in ur dialplan, placing ur c@lls" #This so I see
it in stdout
cmd "bridge", "sofia/#{context}/#{extension}"
end

I didn't do extensive testing, but I was able to send the call off
both to another sip phone and out a gateway to my PSTN provider.

-Dan
Reply all
Reply to author
Forward
0 new messages