Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

no auth request received - if delay in socket connection #8

Closed
padmanabanravikumar opened this issue Mar 2, 2015 · 11 comments
Closed

Comments

@padmanabanravikumar
Copy link

"No Auth Request received within the specified timeout of 00:00:05" exception thrown when using NLog with database logging. If i remove NLog then everything works fine.

var socket = new InboundSocket(host, port, timeout);

await
socket.Messages.Where(x => x.ContentType == ContentTypes.AuthRequest)
.Take(1)
.Timeout(
socket.ResponseTimeOut,
Observable.Throw(
new TimeoutException(
"No Auth Request received within the specified timeout of {0}.".Fmt(socket.ResponseTimeOut))))
.Do(_ => Log.Trace(() => "Received Auth Request"), ex => Log.ErrorException("Error waiting for AuthRequest.", ex))
.ToTask();

In these statements, If there is no delay in execution between these two statements it just works fine. and if there is a delay executing the second statement then it always fails.

for example, if we add the "System.Threading.Thread.Sleep(50);" in between the above two statements then second statement always fails and throws "No Auth Request received within the specified timeout of 00:00:05" exception.

@danbarua
Copy link
Owner

danbarua commented Mar 2, 2015

Hi @padmanabanravikumar , I am on the fence as to whether we ought to remove the response timeout code altogether (you will see that it is marked with the [Obsolete] attribute in the codebase.)

However, if you are using database logging with NLog, then perhaps you might benefit from wrapping your database logging in an async target: https://github.com/nlog/NLog/wiki/AsyncWrapper-target
This will keep the NEventSocket worker threads from blocking and is generally worth doing if your log writes are going to be non-trivial.

Since working with FreeSwitch can involve a lot of trial and error, NEventSocket can be quite chatty with its logs to give you as much information as possible, you might also want to filter out Trace and Debug level logs from going to the DB.

@padmanabanravikumar
Copy link
Author

thank you for your support. its working fine now.
i have one more issue. sometimes "StartDtmf" function call does not working well, no response received after a long period of waiting.
i have debugged for a while and noticed in EventSocket.cs file line 238 the method "SendCommand" call never happens.

@danbarua
Copy link
Owner

danbarua commented Mar 2, 2015

Is this an Inbound socket controlling many channels or with just one channel?

@danbarua
Copy link
Owner

danbarua commented Mar 2, 2015

Have you tried calling socket.SubscribeEvents() after connecting?

@padmanabanravikumar
Copy link
Author

i am just using one channel.
i have called client.SubscribeEvents(EventName.Dtmf).

@danbarua
Copy link
Owner

danbarua commented Mar 3, 2015

Let's move this discussion to the chat room: https://gitter.im/danbarua/NEventSocket
I might need you to paste me some trace level logs.

@danbarua
Copy link
Owner

danbarua commented Mar 3, 2015

I've managed to replicate this now. Using LINQ queries with Rx is nice but sometimes you get race conditions where the message you want has arrived before the subscriber has been hooked up.

@padmanabanravikumar
Copy link
Author

Is there any workaround?

@danbarua
Copy link
Owner

danbarua commented Mar 3, 2015

Try the latest code, it should be ok now - v0.3.0 is up on NuGet.

@danbarua
Copy link
Owner

danbarua commented Mar 5, 2015

@padmanabanravikumar Did this work for you?

@padmanabanravikumar
Copy link
Author

yes, thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants