Problem using API's and try-catch

17 views
Skip to first unread message

Danielzt

unread,
May 14, 2012, 10:34:02 PM5/14/12
to Liverpie Support
Hi Alex

First of all, thanks for your awesome work. I'm being trying to use
the ESL with PHP but found several incompatibilities... Then tried the
Event Socket direct with a PHP socket. But the raw messages where
driving me crazy. So I found liverpie! =)

Well, my first impression was really surprised. The entire
communication layer problem was solved, but now, a few days using, I
found some problems.

Could you help me fixing of find a solution to them? The first 1 is
solved...

1) In some situations, i had to wait for 2 commands. For instance,
"conference". I wanted to know when the user entered the conference
and them, when the user finished the conference. So, CHANNEL_EXECUTE
and CHANNEL_EXECUTE_COMPLETED are the possible responses.

For this scenario, i found a simple solution. Lines changed:
65: if (@params[@expected_key] == @expected_value) or
(@params[@expected_key] == @expected_value2)
71: @expected_key, @expected_value, @expected_value2 =
yaml['expected_key'], yaml['expected_value'], yaml['expected_value2']

2) When user API functions, like, get the number of users in some
conference room (), the answer is not standardized like others. See
below:
"Content-Type: api/response
Content-Length: 119

5;sofia/internal/10...@192.168.56.102;efc0e468-9e35-11e1-
a8fd-7d13150cac9e;1000;1000;hear|speak|talking|floor;0;0;0;300
"
The finish of the command is not \n\n, so liverpie receive the content-
length and keep waiting for the next command. When it receives, the
response gives error.

3) For some scenarios like the previous one, liverpie just dies. For a
telephony server, this is unaceptable. How to proper implement some
try-catch on the software?


Thanks in advance and congratulations for this great software.

alexand...@gmail.com

unread,
May 15, 2012, 12:48:52 AM5/15/12
to Liverpie Support
Hi Daniel,

Thank you for your feedback and compliments.

I am currently away for a few weeks and so I cannot reproduce your
issues because I've no Freeswitch at hand, but:

1. You seem to have found a decent solution. I'll incorporate it into
the next version when I'll have time to release it, thank you; but
I'll don't think that hardcoding a secondary expected value is the way
to go. I'll think about an array of expected values. It's a very good
point.

2. Obviously the Freeswitch doc pretty much guarantee that two
newlines will be sent after each response, so if that doesn't hold
true, I'm not sure what I can do. A single newline can be very common
and I can't parse for that. I suppose I should stop when I've reached
content-length. I'll give that a go.

3. I couldn't make it crash, and the "try-catch" (which in Ruby is
called begin-rescue) mechanism is implemented in the major places, but
it's possible I've neglected some. As you can see, the app has not yet
gained its first major version point.

When I'm back and have time to fix these issues I'll do so and release
again; will keep you posted on this forum. In the meantime, I don't
even have Freeswitch :)

Thanks again,

Alex
> 5;sofia/internal/1...@192.168.56.102;efc0e468-9e35-11e1-

Danielzt

unread,
May 15, 2012, 7:16:42 AM5/15/12
to Liverpie Support
Thanks for your quick answer!

The issue explained on point 2, caused the crash bellow on:

SendMsg 8d13fa5b-f8da-4f5e-ae8e-2f4c6655de1b
call-command: execute
execute-app-name: conference
execute-app-arg: 2222
event-lock: true
Tue May 15 02:17:29 UTC 2012: Data Received (content-type: command/
reply):
Content-Type: command/reply
Reply-Text: +OK


Tue May 15 02:17:29 UTC 2012: Waiting for params[event_name] to be
CHANNEL_EXECUTE_COMPLETE or CHANNEL_EXECUTE or event_name be
CHANNEL_HANGUP.
Disconnected from Freeswitch
Tue May 15 02:17:29 UTC 2012: Data Received (content-type: text/event-
plain):
"Content-Length: 6358
Content-Type: text/event-plain

Event-Name: CHANNEL_EXECUTE
Core-UUID: 70f9dc4e-4044-4821-8728-22f204ef4f35
FreeSWITCH-Hostname: freeswitch
...
Application: conference
Application-Data: 2222

"

Tue May 15 02:17:29 UTC 2012: Waiting for params[event_name] to be
CHANNEL_EXECUTE_COMPLETE or CHANNEL_EXECUTE
Tue May 15 02:17:29 UTC 2012: Calling webapp my_webapp...
Tue May 15 02:17:29 UTC 2012: Got webapp response for runner method
Tue May 15 02:17:29 UTC 2012: Sending:
api conference 2222 list

Disconnected from Freeswitch
** Exiting **
** Exiting... **
./lib/liverpie_server.rb:100:in `hashify': undefined method `strip'
for nil:NilClass (NoMethodError)
from ./lib/liverpie_server.rb:99:in `each'
from ./lib/liverpie_server.rb:99:in `hashify'
from ./lib/liverpie_server.rb:33:in `receive_data'
from /usr/lib/ruby/1.8/eventmachine.rb:257:in `run_machine'
from /usr/lib/ruby/1.8/eventmachine.rb:257:in `run'
from ./bin/liverpie:25
from ./lib/script_base.rb:85:in `start'
from ./lib/script_base.rb:52:in `initialize'
from ./bin/liverpie:24:in `new'
from ./bin/liverpie:24

As you can see, Liverpie tried to parse this info and failed.
5;sofia/internal/1...@192.168.56.102;efc0e468-9e35-11e1-
a8fd-7d13150cac9e;1000;1000;hear|speak|talking|floor;0;0;0;300

BTW, i'm using this API method just to get the conference_member_id
for the current user. Do you know a simpler way?

Thanks
On 15 maio, 01:48, "a...@indigenious.ro" <alexandru.d...@gmail.com>
wrote:

Danielzt

unread,
May 15, 2012, 8:20:37 AM5/15/12
to Liverpie Support
Just to keep informed, I found a workaround for my problem. After
entering a conference and issuing the command "connect" again, FS
sends back all info of the channel and also, the member_id.

But would be good to be able to send API commands.

Thanks
Reply all
Reply to author
Forward
0 new messages