Reputation: 5972
I have a NancyFX
API, and when one of the endpoints is hit, I need to kick of a longer running asynchonous task that's decoupled from the endpoint itself. So I'm trying to use a Azure Service Bus
queue.
I'm successfully writing a message to the queue when the NancyFX
endpoint is hit. I can also successfully subscribe and read from the queue from something other than NancyFX
(I tested from Linqpad).
However, if I try to subscribe from the NancyFX
app, I get a timeout exception within a second or two from starting the app. I'm doing this in another thread which is kicked off from the NancyFX
Bootstrapper.ApplicationStartup
override.
I'm unsure why this would be different than doing it not in the NancyFX
app. I can't see anything of relevance in the web.config
file.
Below is the code I'm using to subscribe to the queue ...
var tokenProvider = TokenProvider.CreateSharedAccessSignatureTokenProvider("Main", AccessKey);
var factory = await MessagingFactory.CreateAsync("sb://myapp.servicebus.windows.net", tokenProvider);
var receiver = await factory.CreateMessageReceiverAsync("MyQueue");
receiver.OnMessage(bm =>
{
// Do something here
}, new OnMessageOptions
{
MaxConcurrentCalls = 1,
});
Below is the exception ...
System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: A timeout has occurred during the operation. b6b8e25a-714f-4f55-8a79-91e390f47a96_G25 (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.TimeoutException: A timeout has occurred during the operation. ).
And here is the callstack when I caught it in the debugger ...
Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.ThrowIfFaultMessage(System.ServiceModel.Channels.Message wcfMessage) Line 463 C# Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.HandleMessageReceived(System.IAsyncResult result) Line 313 C# Microsoft.ServiceBus.dll!Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.OnMessageReceived(System.IAsyncResult result) Line 381 C# System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) Unknown System.ServiceModel.dll!System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(System.IAsyncResult result) Unknown System.ServiceModel.Internals.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result) Unknown System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) Unknown System.ServiceModel.dll!System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(object state) Unknown System.ServiceModel.dll!System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(object state) Unknown System.ServiceModel.Internals.dll!System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(System.IAsyncResult result) Unknown System.dll!System.Net.LazyAsyncResult.Complete(System.IntPtr userToken) Unknown System.dll!System.Net.LazyAsyncResult.ProtectedInvokeCallback(object result, System.IntPtr userToken) Unknown System.dll!System.Net.Security._SslStream.ProcessFrameBody(int readBytes, byte[] buffer, int offset, int count, System.Net.AsyncProtocolRequest asyncRequest) Unknown System.dll!System.Net.Security._SslStream.ReadFrameCallback(System.Net.AsyncProtocolRequest asyncRequest) Unknown System.dll!System.Net.AsyncProtocolRequest.CompleteRequest(int result) Unknown System.dll!System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(int bytes) Unknown System.dll!System.Net.FixedSizeReader.ReadCallback(System.IAsyncResult transportResult) Unknown System.ServiceModel.Internals.dll!System.Runtime.AsyncResult.Complete(bool completedSynchronously) Unknown System.ServiceModel.dll!System.ServiceModel.Channels.ConnectionStream.IOAsyncResult.OnAsyncIOComplete(object state) Unknown System.dll!System.Net.Sockets.SocketAsyncEventArgs.OnCompleted(System.Net.Sockets.SocketAsyncEventArgs e) Unknown System.dll!System.Net.Sockets.SocketAsyncEventArgs.FinishOperationSuccess(System.Net.Sockets.SocketError socketError, int bytesTransferred, System.Net.Sockets.SocketFlags flags) Unknown System.dll!System.Net.Sockets.SocketAsyncEventArgs.CompletionPortCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* nativeOverlapped) Unknown mscorlib.dll!System.Threading._IOCompletionCallback.PerformIOCompletionCallback(uint errorCode, uint numBytes, System.Threading.NativeOverlapped* pOVERLAP) Unknown [Native to Managed Transition]
Upvotes: 0
Views: 370
Reputation: 25994
The exception you got is an indication of the client not being able to go past ASB gateway to talk to the backend. You could use the provided tracking ID (b6b8e25a-714f-4f55-8a79-91e390f47a96_G25
) to open a support case. In case that exception persists, try a different namespace to see if that rules it out.
Upvotes: 1