0
lua: els_bgapi.lua:20: attempt to index global 'e_con' (a number value)
stack traceback:
        els_bgapi.lua:20: in main chunk
        [C]: in ?

Please help me am new to Lua and FreeSWITCH when ran the code below got the error above

sock:bgapi("originate","{sip_cid_type=pid,origination_uuid=uuid,origination_caller_id_number=65181,originate_timeout=10}sofia/external/sip:81245@10.20.16.135 5000")

e_con= sock:events("plain","all");
if (e_con) then
  print(e_con:getHeader());
else
  print("not e_con")
end
2
  • 2
    It seems that sock:events returns a number, not an object that you can call getHeader on.
    – lhf
    Mar 10, 2017 at 14:14
  • @EgorSkriptunoff Job-uuid is number something like this: +OK Job-UUID: f719939a-ffa1-49ca-a8b6-7f080febc2dc.
    – daptim
    Mar 10, 2017 at 16:49

1 Answer 1

0

events command just do subscribe to events but not read any events from connection.

bgapi works like you send command to FS. FS returns reply with job id. But in this time FS may not start execute command yeat. You have to wait BACKGROUND_JOB event with correct job id.

So you have to subscribe to BACKGROUND_JOB (or to all like you do but be prepare to handle many other events).

Then send bgapi and read job uuid from response or pass your own job uuid so you can filter events before you get response form FS. Then do loop with recvEvent.

I do not use original ESL library but there exists examples in FS books. Also I works on my own ESL implementation for Lua base on LibUV library

2
  • you are correct i subscribed e = sock:sendRecv("events plain all") and set e = sock:recvEventTimed(30), job_uuid = e:getHeader("Job-UUID"); so with that I got the Job_uuid.
    – daptim
    Mar 13, 2017 at 8:17
  • you are correct i subscribed e = sock:sendRecv("events plain all") and set e = sock:recvEventTimed(30), job_uuid = e:getHeader("Job-UUID"); so with that I got the Job_uuid.please i would to know how to implement ESL using LibUV Library I will appreciate any documentation on this. kindly pardon my ignorance am a lua beginner.
    – daptim
    Mar 13, 2017 at 9:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.