danbarua / NEventSocket

A reactive FreeSwitch eventsocket library for Modern .Net
Mozilla Public License 2.0
74 stars 37 forks source link

Async hanging #27

Closed mguerrieri closed 8 years ago

mguerrieri commented 8 years ago

Running the KitchenSink demo, with the DtmfTest() method, my socket connects fine and the "await originate" call triggers a dial/park on my extension, but the originate call never returns- it hangs on the await. Any thoughts as to why this would be? I am running against the most recent dev build of FreeSWITCH (1.7) on Windows.

Any help would be greatly appreciated.

danbarua commented 8 years ago

Can you paste a Trace level log output here? And also show me how you are making the originate call.

danbarua commented 8 years ago

Oh and one more thing - make sure you are calling the eventsocket dialplan application with the async full arguments - otherwise the originate dialplan application will block until the call has completed and hungup.

danbarua commented 8 years ago

Oh and yes, I forgot - you need to call eventSocket.SubscribeEvents() to receive the events that indicate that the originate has completed. Note that in the next release NEventSocket will hook up the events subscriptions for you as needed.

mguerrieri commented 8 years ago

How does that work with an inbound socket where the app is originating a call? The app is connecting the socket and registering for events unrelated to any dialplan, is it not? Mark Guerrieri JMB Technology, LLC www.jmbtech.net | 215-431-4156 On Feb 6, 2016 8:55 AM, Dan Barua notifications@github.com wrote:Oh and one more thing - make sure you are calling the eventsocket dialplan application with the async full arguments - otherwise the originate dialplan application will block until the call has completed and hungup.

—Reply to this email directly or view it on GitHub.

danbarua commented 8 years ago

We need a few bare minimum events to figure out the status of an originate call.

Right now, a call to .SubscribeEvents() will subscribe to the following - we need BackgroundJob, ChannelExecuteComplete and ChannelAnswer track the progress of an originate.

EventName.ChannelExecuteComplete,
EventName.BackgroundJob,
EventName.ChannelHangup, 
EventName.ChannelAnswer, 
EventName.ChannelProgress, 
EventName.ChannelProgressMedia, 
EventName.ChannelBridge, 
EventName.ChannelUnbridge

It's one of those things that's not immediately obvious unless you have paid close attention to the README.

For this reason, I will be introducing a breaking change (https://github.com/danbarua/NEventSocket/pull/25) to make things simpler/

mguerrieri commented 8 years ago

I added .SubScribeEvents() to the top of the DtmfTest() method- doing this I have discovered that if the originate fails (in my case due to an unregistered user error) the originate method still hangs on await. Maybe I need to subscribe to some other event not included in the defaults to catch this failure?

Once I registered my station, the test app now runs, although I am still not receiving DTMF events when pressing buttons on my softphone. Still investigating to see if this is an issue on my end.

mguerrieri commented 8 years ago

Actually, ignore the above comment; it did not hang on await- that was user error on my part- sorry!

danbarua commented 8 years ago

Hi, I've reproduced it my end - it's definitely the example code, I've not touched that particular piece in a long while! I need to tidy up and organise the samples.

mguerrieri commented 8 years ago

Thanks- appreciate you looking into it!

Mark Guerrieri

http://www.jmbtech.net/ JMB Technology, LLC

215-431-4156

mguerrieri@jmbtech.net

From: Dan Barua [mailto:notifications@github.com] Sent: Friday, February 19, 2016 11:04 AM To: danbarua/NEventSocket NEventSocket@noreply.github.com Cc: Mark Guerrieri mguerrieri@jmbtech.net Subject: Re: [NEventSocket] Async hanging (#27)

Hi, I've reproduced it my end - it's definitely the example code, I've not touched that particular piece in a long while! I need to tidy up and organise the samples.

— Reply to this email directly or view it on GitHub https://github.com/danbarua/NEventSocket/issues/27#issuecomment-186277490 . https://github.com/notifications/beacon/AEGPVQgF7aLS9ElLriAeso_HF76miChcks5plzRkgaJpZM4HU0Vd.gif

danbarua commented 8 years ago

@mguerrieri examples have moved to src/examples

Note: When running as a console app, Console.Readline() can block the event pump threads, so we use a slightly different method to wait for user input: https://github.com/danbarua/NEventSocket/blob/master/src/NEventSocket.Examples/Examples/DtmfExample.cs#L79 In production you would be running as a service/daemon and so would not have this issue.