Hello All, I have some problem with receiving and handling ESL events. My code is like: void handle_eslswitch_event_plain(esl_handle_t *handle, esl_event_t *event) { ... ... TRACE_DEBUG("ESL event [%d] %s: UUID: %s", event->event_id, fs_get_event_header(event, "Event-Name"), uniqueid); print_event(event); ... ... } void handle_event(esl_handle_t *handle, esl_event_t *last_event) { ... ... if (!strcasecmp(type, "text/event-plain")) { handle_eslswitch_event_plain(handle, handle->last_ievent); } ... ... } int main() { ... ... //receive from event socket if (handle.last_event) handle_event(&handle, handle.last_event); ... ... Usually I receive correct events. But I occasionally receive incorrect event. See below the 1st is the normal event and the 2nd is the wrong event: <2011-07-29 14:25:29> [DEBUG] ESL event [8] CHANNEL_HANGUP_COMPLETE: UUID: f320e4a6-db23-46d0-8d89-9957eccbd4c9 <2011-07-29 14:25:29> [DEBUG] RECV EVENT Event-Name: CHANNEL_HANGUP_COMPLETE Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72 FreeSWITCH-Hostname: fs01 FreeSWITCH-IPv4: 10.1.1.46 FreeSWITCH-IPv6: ::1 Event-Date-Local: 2011-07-29 14:25:29 However, usually after failure in executing "hangup" and getting "-ERR ..." in the event->last_sr_reply, I have wrong event, but not always (an -ERR returned from executing "hangup" doesn't always result in a wrong event). Here it is: <2011-07-29 14:25:29> [NOTICE] -ERR invalid session id [f320e4a6-db23-46d0-8d89-9957eccbd4c9] <2011-07-28 15:55:23> [DEBUG] ESL event [0] : UUID: <2011-07-28 15:55:23> [DEBUG] RECV EVENT Content-Length: 6485 Content-Type: text/event-plain Event-Name: CHANNEL_HANGUP Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72 FreeSWITCH-Hostname: fs01 FreeSWITCH-IPv4: 10.1.1.46 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2011-07-28%2015%3A55%3A23 In the above case, both Event ID and UUID are invalid. I think i need more information regarding how to use the data elements in ESL event, especially how to use the following: char last_reply[1024]; /*! Las command reply when called with esl_send_recv */ char last_sr_reply[1024]; /*! Last event received. Only populated when **save_event is NULL */ esl_event_t *last_event; /*! Last event received when called by esl_send_recv */ esl_event_t *last_sr_event; /*! This will hold already processed events queued by esl_recv_event */ esl_event_t *race_event; /*! Events that have content-type == text/plain and a body */ esl_event_t *last_ievent; My questions, what event should I check if I am interested in only channel/call related events, and how? Do I check handle.last_event, or handle.last_ievent, or what? Else, when checking command reply, do I check last_sr_reply, or last_sr_event->body? Please kindly advice. Thanks, D.Ma -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Receiving-junk-ESL-events-tp66... Sent from the freeswitch-users mailing list archive at Nabble.com.
the events are async so you can't count on the next event returned to be a reply to one you sent. you need to use the api command and uuid_kill to do the hangup char cmd[128]; snprintf(cmd, sizeof(cmd), "api uuid_kill %s\n\n", some_uuid); esl_send_recv(&handle, cmd); this function actually guarantees a reply On Wed, Aug 3, 2011 at 2:10 AM, dma <mays.david@gmail.com> wrote:
Hello All,
I have some problem with receiving and handling ESL events.
My code is like:
void handle_eslswitch_event_plain(esl_handle_t *handle, esl_event_t *event) { ... ... TRACE_DEBUG("ESL event [%d] %s: UUID: %s", event->event_id, fs_get_event_header(event, "Event-Name"), uniqueid); print_event(event); ... ... }
void handle_event(esl_handle_t *handle, esl_event_t *last_event) { ... ... if (!strcasecmp(type, "text/event-plain")) { handle_eslswitch_event_plain(handle, handle->last_ievent); } ... ... }
int main() { ... ... //receive from event socket if (handle.last_event) handle_event(&handle, handle.last_event); ... ...
Usually I receive correct events. But I occasionally receive incorrect event. See below the 1st is the normal event and the 2nd is the wrong event:
<2011-07-29 14:25:29> [DEBUG] ESL event [8] CHANNEL_HANGUP_COMPLETE: UUID: f320e4a6-db23-46d0-8d89-9957eccbd4c9 <2011-07-29 14:25:29> [DEBUG] RECV EVENT Event-Name: CHANNEL_HANGUP_COMPLETE Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72 FreeSWITCH-Hostname: fs01 FreeSWITCH-IPv4: 10.1.1.46 FreeSWITCH-IPv6: ::1 Event-Date-Local: 2011-07-29 14:25:29
However, usually after failure in executing "hangup" and getting "-ERR ..." in the event->last_sr_reply, I have wrong event, but not always (an -ERR returned from executing "hangup" doesn't always result in a wrong event). Here it is:
<2011-07-29 14:25:29> [NOTICE] -ERR invalid session id [f320e4a6-db23-46d0-8d89-9957eccbd4c9] <2011-07-28 15:55:23> [DEBUG] ESL event [0] : UUID: <2011-07-28 15:55:23> [DEBUG] RECV EVENT Content-Length: 6485 Content-Type: text/event-plain
Event-Name: CHANNEL_HANGUP Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72 FreeSWITCH-Hostname: fs01 FreeSWITCH-IPv4: 10.1.1.46 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2011-07-28%2015%3A55%3A23
In the above case, both Event ID and UUID are invalid.
I think i need more information regarding how to use the data elements in ESL event, especially how to use the following:
char last_reply[1024]; /*! Las command reply when called with esl_send_recv */ char last_sr_reply[1024]; /*! Last event received. Only populated when **save_event is NULL */ esl_event_t *last_event; /*! Last event received when called by esl_send_recv */ esl_event_t *last_sr_event; /*! This will hold already processed events queued by esl_recv_event */ esl_event_t *race_event; /*! Events that have content-type == text/plain and a body */ esl_event_t *last_ievent;
My questions, what event should I check if I am interested in only channel/call related events, and how? Do I check handle.last_event, or handle.last_ievent, or what?
Else, when checking command reply, do I check last_sr_reply, or last_sr_event->body?
Please kindly advice.
Thanks, D.Ma
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Receiving-junk-ESL-events-tp66... Sent from the freeswitch-users mailing list archive at Nabble.com.
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
Hi Anthony, Thanks a lot for the solution. I shall try uuid_kill. I am currently using "sendmsg" to "hangup" a UUID call, like this: snprintf(cmd, sizeof(cmd), "sendmsg %s\ncall-command: hangup\nhangup-cause: .... I send the message using esl_send_recv() and check handle.last_sr_reply immediately after the function returns. Now I realize this is wrong because "sendmsg" is async and "api uuid_kill" can guarantee a reply. Thanks again, D.Ma On Thu, Aug 4, 2011 at 12:44 PM, Anthony Minessale < anthony.minessale@gmail.com> wrote:
the events are async so you can't count on the next event returned to be a reply to one you sent. you need to use the api command and uuid_kill to do the hangup
char cmd[128]; snprintf(cmd, sizeof(cmd), "api uuid_kill %s\n\n", some_uuid);
esl_send_recv(&handle, cmd);
this function actually guarantees a reply
On Wed, Aug 3, 2011 at 2:10 AM, dma <mays.david@gmail.com> wrote:
Hello All,
I have some problem with receiving and handling ESL events.
My code is like:
void handle_eslswitch_event_plain(esl_handle_t *handle, esl_event_t *event) { ... ... TRACE_DEBUG("ESL event [%d] %s: UUID: %s", event->event_id, fs_get_event_header(event, "Event-Name"), uniqueid); print_event(event); ... ... }
void handle_event(esl_handle_t *handle, esl_event_t *last_event) { ... ... if (!strcasecmp(type, "text/event-plain")) { handle_eslswitch_event_plain(handle, handle->last_ievent); } ... ... }
int main() { ... ... //receive from event socket if (handle.last_event) handle_event(&handle, handle.last_event); ... ...
Usually I receive correct events. But I occasionally receive incorrect event. See below the 1st is the normal event and the 2nd is the wrong event:
<2011-07-29 14:25:29> [DEBUG] ESL event [8] CHANNEL_HANGUP_COMPLETE: UUID: f320e4a6-db23-46d0-8d89-9957eccbd4c9 <2011-07-29 14:25:29> [DEBUG] RECV EVENT Event-Name: CHANNEL_HANGUP_COMPLETE Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72 FreeSWITCH-Hostname: fs01 FreeSWITCH-IPv4: 10.1.1.46 FreeSWITCH-IPv6: ::1 Event-Date-Local: 2011-07-29 14:25:29
However, usually after failure in executing "hangup" and getting "-ERR ..." in the event->last_sr_reply, I have wrong event, but not always (an -ERR returned from executing "hangup" doesn't always result in a wrong event). Here it is:
<2011-07-29 14:25:29> [NOTICE] -ERR invalid session id [f320e4a6-db23-46d0-8d89-9957eccbd4c9] <2011-07-28 15:55:23> [DEBUG] ESL event [0] : UUID: <2011-07-28 15:55:23> [DEBUG] RECV EVENT Content-Length: 6485 Content-Type: text/event-plain
Event-Name: CHANNEL_HANGUP Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72 FreeSWITCH-Hostname: fs01 FreeSWITCH-IPv4: 10.1.1.46 FreeSWITCH-IPv6: %3A%3A1 Event-Date-Local: 2011-07-28%2015%3A55%3A23
In the above case, both Event ID and UUID are invalid.
I think i need more information regarding how to use the data elements in ESL event, especially how to use the following:
char last_reply[1024]; /*! Las command reply when called with esl_send_recv */ char last_sr_reply[1024]; /*! Last event received. Only populated when **save_event is NULL */ esl_event_t *last_event; /*! Last event received when called by esl_send_recv */ esl_event_t *last_sr_event; /*! This will hold already processed events queued by esl_recv_event */ esl_event_t *race_event; /*! Events that have content-type == text/plain and a body */ esl_event_t *last_ievent;
My questions, what event should I check if I am interested in only channel/call related events, and how? Do I check handle.last_event, or handle.last_ievent, or what?
Else, when checking command reply, do I check last_sr_reply, or last_sr_event->body?
Please kindly advice.
Thanks, D.Ma
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Receiving-junk-ESL-events-tp66... Sent from the freeswitch-users mailing list archive at Nabble.com.
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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
-- Anthony Minessale II
FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire
AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch
FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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
participants (3)
-
Anthony Minessale
-
David Ma
-
dma