Sponsor: VoiceMeUp - Corporate & Wholesale VoIP Services

VoIP Mailing List Archives
Mailing list archives for the VoIP community
 SearchSearch 

[Freeswitch-users] Originating a call from lua with rudimentary error checking


 
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users
View previous topic :: View next topic  
Author Message
john at feith.com
Guest





PostPosted: Wed Jun 24, 2009 8:15 pm    Post subject: [Freeswitch-users] Originating a call from lua with rudiment Reply with quote

I have a lua script that originates a call:

local s = freeswitch.Session (
"{ignore_early_media=true,origination_caller_id_name=" ..
caller .. "}loopback/" .. destination .. "/default/XML")

s:execute ("sleep", "1000")

...

which works fine if a valid number is supplied. However if
a invalid number is supplied, then the script hits:

[ERR] switch_cpp.cpp:607 session is not initalized
[ERR] freeswitch_lua.cpp:102 session is not initalized

What's the recommended way to check if the session constructor was
successful (i.e. the number could be dialed)?

My other option is:

local s = freeswitch.Session ()

local r = s:originate (nil,
"{ignore_early_media=true,origination_caller_id_name=" ..
caller .. "}loopback/" .. destination .. "/default/XML", 300)

if r == 1 then
stream:write ("-ERR call failed\n")
return
end

which does handle invalid numbers however there are the minor issues such as:

a) The documentation seems to strongly discourage using the originate
method for some reason.

b) The lua originate method seems to require timeout to be specified
even though the documentation implies it's optional.

c) Using this approach causes the message:

[WARNING] mod_limit.c:576 USAGE: hash [insert|delete]/<realm>/<key>/<val>

which I have yet to track down.

Thoughts?

-- John
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------


_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
brian at freeswitch.org
Guest





PostPosted: Thu Jun 25, 2009 3:21 am    Post subject: [Freeswitch-users] Originating a call from lua with rudiment Reply with quote

check that s is nil.

/b

On Jun 24, 2009, at 8:12 PM, John Wehle wrote:
Quote:
What's the recommended way to check if the session constructor was
successful (i.e. the number could be dialed)?


Brian West
brian@freeswitch.org (brian@freeswitch.org)



-- Meet us at ClueCon! http://www.cluecon.com
Back to top
anthony.minessale at g...
Guest





PostPosted: Thu Jun 25, 2009 8:29 am    Post subject: [Freeswitch-users] Originating a call from lua with rudiment Reply with quote

and that s.ready() is true


On Thu, Jun 25, 2009 at 3:20 AM, Brian West <brian@freeswitch.org (brian@freeswitch.org)> wrote:
Quote:
check that s is nil.

/b

On Jun 24, 2009, at 8:12 PM, John Wehle wrote:

Quote:
What's the recommended way to check if the session constructor was
successful (i.e. the number could be dialed)?



Brian West
brian@freeswitch.org (brian@freeswitch.org)



-- Meet us at ClueCon!  http://www.cluecon.com











_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org (Freeswitch-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org




--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400
Back to top
john at feith.com
Guest





PostPosted: Thu Jun 25, 2009 2:38 pm    Post subject: [Freeswitch-users] Originating a call from lua with rudiment Reply with quote

Quote:
Quote:
What's the recommended way to check if the session constructor was
successful (i.e. the number could be dialed)?

Quote:
check that s is nil.

Doesn't work ... s is never nil. Type shows it as userdata
even if Session failed. Specifically my test was:

local s = freeswitch.Session (
"{ignore_early_media=true,origination_caller_id_name=" ..
caller .. "}loopback/" .. destination .. "/default/XML")

stream:write (type(s))

if s == nil then
stream:write ("-ERR call failed\n")
return
end

and I dialed an unreachable number.

Quote:
and that s.ready() is true

Checking s.ready() results in:

[ERR] freeswitch_lua.cpp:102 session is not initalized

if Session failed.

What I'm looking for is a way to try to originate a call which doesn't
throw ERR messages if the attempt fails.

Explicitly calling session.originate seems to allow you to check if
the call was successful ... is there a particular reason it's discouraged?

I'm happy to avoid it if a better approach is available, however I'm
having trouble finding one.

-- John
-------------------------------------------------------------------------
| Feith Systems | Voice: 1-215-646-8000 | Email: john@feith.com |
| John Wehle | Fax: 1-215-540-5495 | |
-------------------------------------------------------------------------


_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Back to top
anthony.minessale at g...
Guest





PostPosted: Thu Jun 25, 2009 2:52 pm    Post subject: [Freeswitch-users] Originating a call from lua with rudiment Reply with quote

I think this is an oversight
update to trunk and session.ready() should work as expected.


On Thu, Jun 25, 2009 at 2:35 PM, John Wehle <john@feith.com (john@feith.com)> wrote:
Quote:
>> What's the recommended way to check if the session constructor was
Quote:
Quote:
successful (i.e. the number could be dialed)?

Quote:
check that s is nil.

Doesn't work ... s is never nil.  Type shows it as userdata
even if Session failed.  Specifically my test was:

 local s = freeswitch.Session (
             "{ignore_early_media=true,origination_caller_id_name=" ..
              caller .. "}loopback/" .. destination .. "/default/XML")

 stream:write (type(s))

 if s == nil then
   stream:write ("-ERR call failed\n")
   return
 end

and I dialed an unreachable number.

Quote:
and that s.ready() is true

Checking s.ready() results in:

 [ERR] freeswitch_lua.cpp:102 session is not initalized

if Session failed.

What I'm looking for is a way to try to originate a call which doesn't
throw ERR messages if the attempt fails.

Explicitly calling session.originate seems to allow you to check if
the call was successful ... is there a particular reason it's discouraged?

I'm happy to avoid it if a better approach is available, however I'm
having trouble finding one.

-- John
-------------------------------------------------------------------------
|   Feith Systems  |   Voice: 1-215-646-8000  |  Email: john@feith.com (john@feith.com)  |
|    John Wehle    |     Fax: 1-215-540-5495  |                         |
-------------------------------------------------------------------------


_______________________________________________
Freeswitch-users mailing list
Freeswitch-users@lists.freeswitch.org (Freeswitch-users@lists.freeswitch.org)
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org



--
Anthony Minessale II

FreeSWITCH http://www.freeswitch.org/
ClueCon http://www.cluecon.com/

AIM: anthm
MSN:anthony_minessale@hotmail.com ([email]MSN%3Aanthony_minessale@hotmail.com[/email])
GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com ([email]PAYPAL%3Aanthony.minessale@gmail.com[/email])
IRC: irc.freenode.net #freeswitch

FreeSWITCH Developer Conference
sip:888@conference.freeswitch.org ([email]sip%3A888@conference.freeswitch.org[/email])
iax:guest@conference.freeswitch.org/888
googletalk:conf+888@conference.freeswitch.org ([email]googletalk%3Aconf%2B888@conference.freeswitch.org[/email])
pstn:213-799-1400
Back to top
Display posts from previous:   
Post new topic   Reply to topic    VoIP Mailing List Archives Forum Index -> freeSWITCH Users All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group

VoiceMeUp - Corporate & Wholesale VoIP Services