Hi Anthony, <br><br>Thanks a lot for the solution. I shall try uuid_kill.<br><br>I am currently using &quot;sendmsg&quot; to &quot;hangup&quot; a UUID call, like this:<br><br>        snprintf(cmd, sizeof(cmd), &quot;sendmsg %s\ncall-command: hangup\nhangup-cause: ....<br>
<br>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 &quot;sendmsg&quot; is async and &quot;api uuid_kill&quot; can guarantee a reply. <br>
<br>Thanks again, <br>D.Ma<br><br><div class="gmail_quote">On Thu, Aug 4, 2011 at 12:44 PM, Anthony Minessale <span dir="ltr">&lt;<a href="mailto:anthony.minessale@gmail.com">anthony.minessale@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">the events are async so you can&#39;t count on the next event returned to<br>
be a reply to one you sent.<br>
you need to use the api command and uuid_kill to do the hangup<br>
<br>
char cmd[128];<br>
snprintf(cmd, sizeof(cmd), &quot;api uuid_kill %s\n\n&quot;, some_uuid);<br>
<br>
esl_send_recv(&amp;handle, cmd);<br>
<br>
this function actually guarantees a reply<br>
<div><div></div><div class="h5"><br>
On Wed, Aug 3, 2011 at 2:10 AM, dma &lt;<a href="mailto:mays.david@gmail.com">mays.david@gmail.com</a>&gt; wrote:<br>
&gt; Hello All,<br>
&gt;<br>
&gt; I have some problem with receiving and handling ESL events.<br>
&gt;<br>
&gt; My code is like:<br>
&gt;<br>
&gt; void handle_eslswitch_event_plain(esl_handle_t *handle, esl_event_t *event)<br>
&gt; {<br>
&gt;        ... ...<br>
&gt;        TRACE_DEBUG(&quot;ESL event [%d] %s: UUID: %s&quot;,<br>
&gt;                event-&gt;event_id, fs_get_event_header(event, &quot;Event-Name&quot;),<br>
&gt; uniqueid);<br>
&gt;         print_event(event);<br>
&gt;        ... ...<br>
&gt; }<br>
&gt;<br>
&gt; void handle_event(esl_handle_t *handle, esl_event_t *last_event)<br>
&gt; {<br>
&gt;        ... ...<br>
&gt;        if (!strcasecmp(type, &quot;text/event-plain&quot;)) {<br>
&gt;            handle_eslswitch_event_plain(handle, handle-&gt;last_ievent);<br>
&gt;        }<br>
&gt;        ... ...<br>
&gt; }<br>
&gt;<br>
&gt; int main()<br>
&gt; {<br>
&gt;        ... ...<br>
&gt;        //receive from event socket<br>
&gt;        if (handle.last_event) handle_event(&amp;handle, handle.last_event);<br>
&gt;        ... ...<br>
&gt;<br>
&gt; Usually I receive correct events. But I occasionally receive incorrect<br>
&gt; event. See below the 1st is the normal event and the 2nd is the wrong event:<br>
&gt;<br>
&gt; &lt;2011-07-29 14:25:29&gt; [DEBUG] ESL event [8] CHANNEL_HANGUP_COMPLETE: UUID:<br>
&gt; f320e4a6-db23-46d0-8d89-9957eccbd4c9<br>
&gt; &lt;2011-07-29 14:25:29&gt; [DEBUG] RECV EVENT<br>
&gt; Event-Name: CHANNEL_HANGUP_COMPLETE<br>
&gt; Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72<br>
&gt; FreeSWITCH-Hostname: fs01<br>
&gt; FreeSWITCH-IPv4: 10.1.1.46<br>
&gt; FreeSWITCH-IPv6: ::1<br>
&gt; Event-Date-Local: 2011-07-29 14:25:29<br>
&gt;<br>
&gt; However, usually after failure in executing &quot;hangup&quot; and getting &quot;-ERR ...&quot;<br>
&gt; in the event-&gt;last_sr_reply, I have wrong event, but not always (an -ERR<br>
&gt; returned from executing &quot;hangup&quot; doesn&#39;t always result in a wrong event).<br>
&gt; Here it is:<br>
&gt;<br>
&gt; &lt;2011-07-29 14:25:29&gt; [NOTICE] -ERR invalid session id<br>
&gt; [f320e4a6-db23-46d0-8d89-9957eccbd4c9]<br>
&gt; &lt;2011-07-28 15:55:23&gt; [DEBUG] ESL event [0] : UUID:<br>
&gt; &lt;2011-07-28 15:55:23&gt; [DEBUG] RECV EVENT<br>
&gt; Content-Length: 6485<br>
&gt; Content-Type: text/event-plain<br>
&gt;<br>
&gt; Event-Name: CHANNEL_HANGUP<br>
&gt; Core-UUID: 26b77cba-8fdd-486d-90ec-6844bca58c72<br>
&gt; FreeSWITCH-Hostname: fs01<br>
&gt; FreeSWITCH-IPv4: 10.1.1.46<br>
&gt; FreeSWITCH-IPv6: %3A%3A1<br>
&gt; Event-Date-Local: 2011-07-28%2015%3A55%3A23<br>
&gt;<br>
&gt; In the above case, both Event ID and UUID are invalid.<br>
&gt;<br>
&gt; I think i need more information regarding how to use the data elements in<br>
&gt; ESL event, especially how to use the following:<br>
&gt;<br>
&gt;    char last_reply[1024];<br>
&gt;    /*! Las command reply when called with esl_send_recv */<br>
&gt;    char last_sr_reply[1024];<br>
&gt;    /*! Last event received. Only populated when **save_event is NULL */<br>
&gt;    esl_event_t *last_event;<br>
&gt;    /*! Last event received when called by esl_send_recv */<br>
&gt;    esl_event_t *last_sr_event;<br>
&gt;    /*! This will hold already processed events queued by esl_recv_event */<br>
&gt;    esl_event_t *race_event;<br>
&gt;    /*! Events that have content-type == text/plain and a body */<br>
&gt;    esl_event_t *last_ievent;<br>
&gt;<br>
&gt; My questions, what event should I check if I am interested in only<br>
&gt; channel/call related events, and how? Do I check handle.last_event, or<br>
&gt; handle.last_ievent, or what?<br>
&gt;<br>
&gt; Else, when checking command reply, do I check last_sr_reply, or<br>
&gt; last_sr_event-&gt;body?<br>
&gt;<br>
&gt; Please kindly advice.<br>
&gt;<br>
&gt; Thanks,<br>
&gt; D.Ma<br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; View this message in context: <a href="http://freeswitch-users.2379917.n2.nabble.com/Receiving-junk-ESL-events-tp6647776p6647776.html" target="_blank">http://freeswitch-users.2379917.n2.nabble.com/Receiving-junk-ESL-events-tp6647776p6647776.html</a><br>

&gt; Sent from the freeswitch-users mailing list archive at Nabble.com.<br>
&gt;<br>
&gt; _______________________________________________<br>
&gt; Join us at ClueCon 2011, Aug 9-11, Chicago<br>
&gt; <a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a> 877-7-4ACLUE<br>
&gt;<br>
&gt; FreeSWITCH-users mailing list<br>
&gt; <a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
&gt; <a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
&gt; UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
&gt; <a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
&gt;<br>
<br>
<br>
<br>
</div></div>--<br>
Anthony Minessale II<br>
<br>
FreeSWITCH <a href="http://www.freeswitch.org/" target="_blank">http://www.freeswitch.org/</a><br>
ClueCon <a href="http://www.cluecon.com/" target="_blank">http://www.cluecon.com/</a><br>
Twitter: <a href="http://twitter.com/FreeSWITCH_wire" target="_blank">http://twitter.com/FreeSWITCH_wire</a><br>
<br>
AIM: anthm<br>
<a href="mailto:MSN%3Aanthony_minessale@hotmail.com">MSN:anthony_minessale@hotmail.com</a><br>
GTALK/JABBER/<a href="mailto:PAYPAL%3Aanthony.minessale@gmail.com">PAYPAL:anthony.minessale@gmail.com</a><br>
IRC: <a href="http://irc.freenode.net" target="_blank">irc.freenode.net</a> #freeswitch<br>
<br>
FreeSWITCH Developer Conference<br>
<a href="mailto:sip%3A888@conference.freeswitch.org">sip:888@conference.freeswitch.org</a><br>
<a href="mailto:googletalk%3Aconf%2B888@conference.freeswitch.org">googletalk:conf+888@conference.freeswitch.org</a><br>
pstn:<a href="tel:%2B19193869900" value="+19193869900">+19193869900</a><br>
<div><div></div><div class="h5"><br>
_______________________________________________<br>
Join us at ClueCon 2011, Aug 9-11, Chicago<br>
<a href="http://www.cluecon.com" target="_blank">http://www.cluecon.com</a> 877-7-4ACLUE<br>
<br>
FreeSWITCH-users mailing list<br>
<a href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</a><br>
<a href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</a><br>
UNSUBSCRIBE:<a href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target="_blank">http://lists.freeswitch.org/mailman/options/freeswitch-users</a><br>
<a href="http://www.freeswitch.org" target="_blank">http://www.freeswitch.org</a><br>
</div></div></blockquote></div><br>