azure service bus timeouts - c#

I'm have 2 topics in my azure service bus.
topic1 = livetopic
topic2 = testtopic
live topic is timing out when I try to add any messages.
If I change my code to use testtopic it is fine.
I've disconnected all my publishers from livetopic still timing out.
I've deleted livetopic and re-added still timing out.
Any ideas on how to solve this.
I've tried using the service bus explorer sample app, it can see both topics, but it also times out on livetopic, but not testtopic.
Below is exception message:
Server stack trace: Exception rethrown at [0]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.DuplexCorrelationAsyncResult.End(IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.b__4(RequestAsyncResult
thisPtr, IAsyncResult r)
at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult
result)
Exception rethrown at [1]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult
asyncResult)
at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.RequestAsyncResult.<>c_DisplayClass17.b_a(RequestAsyncResult
thisPtr, IAsyncResult r)
at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult
result)
Exception rethrown at [2]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult
asyncResult)
at
Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.EndRequest(IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.b__4(RequestAsyncResult
thisPtr, IAsyncResult r)
at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult
result)
Exception rethrown at [3]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult
asyncResult)
at
Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.b__37(TIteratorAsyncResult
thisPtr, IAsyncResult a)
at
Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult
result)
Exception rethrown at [4]:
at
Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult
result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult
asyncResult)
at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult
result)
--- End of inner exception stack trace ---
at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult
result)
at
Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnSend(TrackingContext
trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at
Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext
trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at
Microsoft.ServiceBus.Messaging.MessageSender.Send(BrokeredMessage
message)
at Microsoft.ServiceBus.Messaging.TopicClient.Send(BrokeredMessage
message)
at myCompany.Azure.MessagePublisher.PublishMessage(String topic,
String destinationGroup, String messageCategory, String
destinationApp, String blobStorageDescription) in
c:\codetfs\MyProduct\MyCompany.Azure\MessagePublisher.cs:line 182

Related

C# SOAP Middleware MessageEncoder.WriteMessage

I try to run this tutorial: custom-asp-net-core-middleware-example
But the reponse message at the client say´s:
S
ystem.ServiceModel.ProtocolException: There is a problem with the XML that was received from the network. See inner exception for more details.
---> System.Xml.XmlException: Name cannot begin with the '/' character, hexadecimal value 0x2F. Line 1, position 74.
at System.Xml.XmlExceptionHelper.ThrowXmlException(XmlDictionaryReader reader, XmlException exception)
at System.Xml.XmlUTF8TextReader.VerifyNCName(String s)
at System.Xml.XmlUTF8TextReader.ReadQualifiedName(PrefixHandle prefix, StringHandle localName)
at System.Xml.XmlUTF8TextReader.ReadStartElement()
at System.Xml.XmlUTF8TextReader.Read()
at System.ServiceModel.Channels.Message.ReadStartBody(XmlDictionaryReader reader, EnvelopeVersion envelopeVersion, Boolean& isFault, Boolean& isEmpty)
at System.ServiceModel.Channels.ReceivedMessage.ReadStartBody(XmlDictionaryReader reader)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState, Boolean[] understoodHeaders, Boolean understoodHeadersModified)
at System.ServiceModel.Channels.BufferedMessage..ctor(IBufferedMessageData messageData, RecycledMessageState recycledMessageState)
at System.ServiceModel.Channels.TextMessageEncoderFactory.TextMessageEncoder.ReadMessage(ArraySegment`1 buffer, BufferManager bufferManager, String contentType)
at System.ServiceModel.Channels.MessageEncoder.ReadMessageAsync(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType, CancellationToken cancellationToken)
at System.ServiceModel.Channels.HttpResponseMessageHelper.ReadChunkedBufferedMessageAsync(Task`1 inputStreamTask, TimeoutHelper timeoutHelper)
--- End of inner exception stack trace ---
at System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
at System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass1_0.<CreateGenericTask>b__0(IAsyncResult asyncResult)
I´ve also encounterd a problem with the request-message so I´ve written my own RequestMessage but I´m not sure whether I should write my own ResponseMessage, because I do not know how it should be.
Also I´ve changed the OperationDescription to fit the tutorials code, may there be the problem?
public OperationDescription(ContractDescription contract, MethodInfo operationMethod, OperationContractAttribute contractAttribute)
{
Contract = contract;
SoapAction = contractAttribute.Name ?? operationMethod.Name;
Name = contractAttribute.Action ?? $"{contract.Namespace.TrimEnd('/')}/{contract.Name}/{Name}".Trim('/');
IsOneWay = contractAttribute.IsOneWay;
ReplyAction = contractAttribute.ReplyAction;
DispatchMethod = operationMethod;
}

Occasional exception writing compressed content via WebApi to the client in streamed transfer mode

We have a WEPAPI service, which writes data in compressed form to the client using a message handler. Since we occasional receive very large messages, the system is configured using
HttpSelfHostConfiguration.TransferMode = TransferMode.Streamed;
The compress logic is:
public class CompressedHttpContent : CompressionHttpContent
{
public CompressedHttpContent(HttpContent content, ICompressor compressor)
: base(content, compressor)
{
}
protected async override Task SerializeToStreamAsync(System.IO.Stream stream, System.Net.TransportContext context)
{
try
{
if (this.OriginalContent != null)
using (OriginalContent)
{
using (var contentStream = await OriginalContent.ReadAsStreamAsync())
{
var compressedStream = Compressor.CreateCompressionStream(stream);
await contentStream.CopyToAsync(compressedStream);
compressedStream.Close();
compressedStream.Dispose();
}
}
}
catch (Exception e)
{
...
throw;
}
}
}
And occasionally we get an exception like:
System.InvalidOperationException: The AsyncEventArgs implementation 'System.ServiceModel.Channels.BufferedOutputAsyncStream+WriteAsyncState' tried to set the state to Pending multiple times without completing a pending operation. This could be caused by an incorrect application AsyncEventArgs implementation or other extensibility code that invokes Set() multiple times.
Server stack trace:
at System.Runtime.AsyncEventArgs.set_State(OperationState value)
at System.Runtime.AsyncEventArgs.SetAsyncState(AsyncEventArgsCallback callback, Object state)
at System.Runtime.AsyncEventArgs`1.Set(AsyncEventArgsCallback callback, TArgument arguments, Object state)
at System.ServiceModel.Channels.BufferedOutputAsyncStream.BeginWrite(Byte[] buffer, Int32 offset, Int32 count, AsyncCallback callback, Object state)
at System.IO.Compression.DeflateStream.WriteDeflaterOutput(Boolean isAsync)
at System.IO.Compression.DeflateStream.InternalWrite(Byte[] array, Int32 offset, Int32 count, Boolean isAsync)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
Exception rethrown at [0]:
at System.IO.Compression.DeflateStream.EndWrite(IAsyncResult asyncResult)
at System.IO.Compression.GZipStream.EndWrite(IAsyncResult asyncResult)
at System.IO.Stream.<>c.<BeginEndWriteAsync>b__53_1(Stream stream, IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncTrimPromise`1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.IO.Stream.<CopyToAsyncInternal>d__27.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at CompressedHttpContent.<SerializeToStreamAsync>d__2.MoveNext()
Unfortunately, when I search for this error, I don't get any hits.
We didn't get this when we were using the buffered transfer mode. We could potentially change to StreamedRequest mode, as it's only the incoming requests which can be very large.
Has anyone seen this or have any thoughts?
Thanks.
When experimenting with compressed responses, I encountered the same error.
What I found interesting was the following bit from the source code of BufferedOutputAsyncStream, which appears in the call stack:
" BufferedOutputAsyncStream is not a general-purpose stream wrapper, it requires that the base stream
1. allow concurrent IO (for multiple BeginWrite calls)
2. support the BeginWrite,BeginWrite,BeginWrite,.. Close() calling pattern.
Currently BufferedOutputAsyncStream only used to wrap the System.Net.HttpResponseStream, which satisfy both requirements."
(https://referencesource.microsoft.com/#System.ServiceModel/System/ServiceModel/Channels/BufferedOutputAsyncStream.cs)
This requirement does not appear to be fulfilled for the GZipStream, as can be tested with some simple code (generally throws an exception).
byte[] ba = File.ReadAllBytes(#"largerfile");
GZipStream gzs = new GZipStream(new MemoryStream(), CompressionLevel.Optimal);
gzs.WriteAsync(ba,0, 200000);
gzs.WriteAsync(ba, 0, 200000);
I suspect that ASP.NET WebAPI may be calling the GZipStream in an unsupported manner - although I am not yet convinced that this is actually what's happening.

Resharper not debugging MSTest tests

I'm using Resharper Ultimate 2017.3.1
When I try to debug a unit tests
[DataTestMethod]
[DataRow("bla", "blub")]
public void Test_When_Then() { ... }
Then the test stops debugging, changes to state inconclusive and the following error is shown in the resharper test explorer window:
2018.01.17 13:02:20.367 ERROR Transition failed: Transition from state on event . Cause:
System.ArgumentException: There should be at least one test in the
test run. Parametername: tests --->
System.ServiceModel.FaultException: There should be at least one test
in the test run. Parametername: tests Server stack trace: at
System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
operation, ProxyRpc& rpc) at
System.ServiceModel.Channels.ServiceChannel.Call(String action,
Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout) at
System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation) at
System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message) Exception rethrown at [0]: at
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg) at
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type) at
Microsoft.VisualStudio.TestPlatform.Core.ITestExecutorService.StartTestRun(IEnumerable1
tests, String testRunSettings, TestExecutionContext executionContext,
String dataCollectorServiceUri) at
JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.Wcf.TestExecutorServiceProxy.StartTestRun(IEnumerable1
tests, String testRunSettings, TestExecutionContext executionContext,
String dataCollectorServiceUri) --- End of inner exception stack trace
--- at JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.Wcf.TestExecutorServiceProxy.StartTestRun(IEnumerable1
tests, String testRunSettings, TestExecutionContext executionContext,
String dataCollectorServiceUri) at
JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.MsTestExecutionProtocol.StartTestRun()
at
Appccelerate.StateMachine.Machine.ActionHolders.ArgumentLessActionHolder.Execute(Object
argument) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\ActionHolders\ArgumentLessActionHolder.cs:line
37 at
Appccelerate.StateMachine.Machine.States.State2.ExecuteEntryAction(IActionHolder
actionHolder, ITransitionContext`2 context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
340
--- EXCEPTION #1/1 [LoggerException] Message = “ Transition failed: Transition from state on event .
Cause: System.ArgumentException: There should be at least one test in
the test run. Parametername: tests --->
System.ServiceModel.FaultException: There should be at least one test
in the test run. Parametername: tests
Server stack trace:
at System.ServiceModel.Channels.ServiceChannel.HandleReply(ProxyOperationRuntime
operation, ProxyRpc& rpc)
at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins,
Object[] outs, TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage
methodCall, ProxyOperationRuntime operation)
at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage
message)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage
reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData&
msgData, Int32 type)
at Microsoft.VisualStudio.TestPlatform.Core.ITestExecutorService.StartTestRun(IEnumerable1
tests, String testRunSettings, TestExecutionContext executionContext,
String dataCollectorServiceUri)
at JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.Wcf.TestExecutorServiceProxy.StartTestRun(IEnumerable1
tests, String testRunSettings, TestExecutionContext executionContext,
String dataCollectorServiceUri)
--- End of inner exception stack trace ---
at JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.Wcf.TestExecutorServiceProxy.StartTestRun(IEnumerable1
tests, String testRunSettings, TestExecutionContext executionContext,
String dataCollectorServiceUri)
at JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.MsTestExecutionProtocol.StartTestRun()
at Appccelerate.StateMachine.Machine.ActionHolders.ArgumentLessActionHolder.Execute(Object
argument) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\ActionHolders\ArgumentLessActionHolder.cs:line
37
at Appccelerate.StateMachine.Machine.States.State2.ExecuteEntryAction(IActionHolder
actionHolder, ITransitionContext2 context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
340 ” ExceptionPath = Root ClassName = JetBrains.Util.LoggerException
HResult = COR_E_APPLICATION=80131600 StackTraceString = “ at
JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.MsTestExecutionProtocol.<.ctor>b__10(Object
sender, TransitionExceptionEventArgs2 args)
at Appccelerate.StateMachine.Machine.StateMachine2.RaiseEvent[T](EventHandler1
eventHandler, T arguments, ITransitionContext2 context, Boolean
raiseEventOnException) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\StateMachine.cs:line
404
at Appccelerate.StateMachine.Machine.StateMachine2.OnExceptionThrown(ITransitionContext2
context, Exception exception) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\StateMachine.cs:line
260
at Appccelerate.StateMachine.Machine.Contexts.TransitionContext2.OnExceptionThrown(Exception
exception) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\Contexts\TransitionContext.cs:line
74
at Appccelerate.StateMachine.Machine.States.State2.HandleException(Exception
exception, ITransitionContext2 context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
307
at Appccelerate.StateMachine.Machine.States.State2.HandleEntryActionException(ITransitionContext2
context, Exception exception) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
357
at Appccelerate.StateMachine.Machine.States.State2.ExecuteEntryAction(IActionHolder
actionHolder, ITransitionContext2 context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
345
at Appccelerate.StateMachine.Machine.States.State2.ExecuteEntryActions(ITransitionContext2
context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
330
at Appccelerate.StateMachine.Machine.States.State2.Entry(ITransitionContext2
context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
247
at Appccelerate.StateMachine.Machine.States.State2.EnterShallow(ITransitionContext2
context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
285
at Appccelerate.StateMachine.Machine.States.State2.EnterHistoryNone(ITransitionContext2
context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
429
at Appccelerate.StateMachine.Machine.States.State2.EnterByHistory(ITransitionContext2
context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
263
at Appccelerate.StateMachine.Machine.Transitions.Transition2.Fire(ITransitionContext2
context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\Transitions\Transition.cs:line
87
at Appccelerate.StateMachine.Machine.States.State2.Fire(ITransitionContext2
context) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\States\State.cs:line
222
at Appccelerate.StateMachine.Machine.StateMachine2.Fire(TEvent eventId, Object eventArgument) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\Machine\StateMachine.cs:line
230
at Appccelerate.StateMachine.PassiveStateMachine2.ProcessQueuedEvents()
in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\PassiveStateMachine.cs:line
339
at Appccelerate.StateMachine.PassiveStateMachine2.Execute() in C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\PassiveStateMachine.cs:line
324
at Appccelerate.StateMachine.PassiveStateMachine2.Fire(TEvent eventId, Object eventArgument) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\PassiveStateMachine.cs:line
177
at Appccelerate.StateMachine.PassiveStateMachine2.Fire(TEvent eventId) in
C:\projects\appccelerate\repos\statemachine\source\Appccelerate.StateMachine\PassiveStateMachine.cs:line
163
at JetBrains.ReSharper.UnitTesting.MSTest.Provider.Execution.Wcf.TestExecutorServiceClient.TestConnection(IEnumerable1
dummyTestResults)
at SyncInvokeTestConnection(Object , Object[] , Object[] )
at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]& outputs)
at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&
rpc)
at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)
at System.ServiceModel.Dispatcher.ChannelHandler.DispatchAndReleasePump(RequestContext
request, Boolean cleanThread, OperationContext
currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.HandleRequest(RequestContext
request, OperationContext currentOperationContext)
at System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult
result)
at System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult
result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.TransportDuplexSessionChannel.TryReceiveAsyncResult.OnReceive(IAsyncResult
result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object
state)
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object
state)
at System.ServiceModel.Channels.StreamConnection.OnRead(IAsyncResult
result)
at System.Runtime.Fx.AsyncThunk.UnhandledExceptionFrame(IAsyncResult
result)
at System.Net.LazyAsyncResult.Complete(IntPtr userToken)
at System.Net.LazyAsyncResult.ProtectedInvokeCallback(Object result, IntPtr userToken)
at System.Net.Security.NegotiateStream.ProcessFrameBody(Int32 readBytes, Byte[] buffer, Int32 offset, Int32 count,
AsyncProtocolRequest asyncRequest)
at System.Net.Security.NegotiateStream.ReadCallback(AsyncProtocolRequest
asyncRequest)
at System.Net.AsyncProtocolRequest.CompleteRequest(Int32 result)
at System.Net.FixedSizeReader.CheckCompletionBeforeNextRead(Int32 bytes)
at System.Net.FixedSizeReader.ReadCallback(IAsyncResult transportResult)
at System.Runtime.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.ConnectionStream.IOAsyncResult.OnAsyncIOComplete(Object
state)
at System.ServiceModel.Channels.PipeConnection.OnAsyncReadComplete(Boolean
haveResult, Int32 error, Int32 numBytes)
at System.ServiceModel.Channels.OverlappedContext.CompleteCallback(UInt32
error, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.Runtime.Fx.IOCompletionThunk.UnhandledExceptionFrame(UInt32
error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP) ”
Has anyone had this error too and knows how to fix it so that I can debug my unit tests again?
Thanks in advance
I had this error when updating ReSharper, it turned out to be a problem with the referenced NuGet packages related to Microsoft.VisualStudio.TestPlatform were outdated.
Create a new test project and compare the versions of these assemblies which will be added automatically when the project is created.
Using version 14.0.0.1 is working for me for the following assemblies:
ReSharper 2017.3.1
VS 2017 15.5.3

Castle Windsor throws a CommunicationObjectFaultedException when disposing a WCF client that has thrown a MessageSecurityException

I have an ASP.NET MVC application with a controller that uses a WCF service. The web application is authenticated by the WCF service using WIF and a Security Token Service (STS). This requires that the WCF service has the STS cert thumbprint in its web.config (<system.identityModel>). When a WCF service method is called and the WCF service is configured with a wrong thumbprint the service method throws an exception:
System.AggregateException: One or more errors occurred. ---> System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: An error occurred when processing the security tokens in the message. --- End of inner exception stack trace --- at
System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at
System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at
System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at
System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass5`1.<CreateGenericTask>b__4(IAsyncResult asyncResult) at
System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization) --- End of inner exception stack trace --- at
System.Threading.Tasks.Task`1.GetResultCore(Boolean waitCompletionNotification) at
Helper.GetMessages(String func) in xxx ---> (Inner Exception #0) System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: An error occurred when processing the security tokens in the message. --- End of inner exception stack trace --- at
System.Runtime.AsyncResult.End[TAsyncResult](IAsyncResult result) at
System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result) at
System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result) at
System.ServiceModel.Channels.ServiceChannelProxy.TaskCreator.<>c__DisplayClass5`1.<CreateGenericTask>b__4(IAsyncResult asyncResult) at
System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)<---
In the MVC controller we catch any exceptions thrown by the service since we want to return a response even if there is a problem with the service:
try {
service.Hello();
}
catch (Exception e) {
log.Error("Service error", e);
}
The controller method returns the ViewResult and Castle Windsor starts cleaning up the controller and its dependencies. However when Windsor disposes the WCF client that threw the MessageSecurityException I get this exception:
[CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.]
System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +14579646
System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +622
System.IDisposable.Dispose() +0
Castle.MicroKernel.LifecycleConcerns.DisposalConcern.Apply(ComponentModel model, Object component) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\LifecycleConcerns\DisposalConcern.cs:47
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.ApplyConcerns(IEnumerable`1 steps, Object instance) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\ComponentActivator\AbstractComponentActivator.cs:120
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.ApplyDecommissionConcerns(Object instance) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\ComponentActivator\AbstractComponentActivator.cs:132
Castle.Facilities.WcfIntegration.WcfClientActivator.ApplyDecommissionConcerns(Object instance) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Facilities.WcfIntegration\Client\WcfClientActivator.cs:64
Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalDestroy(Object instance) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\ComponentActivator\DefaultComponentActivator.cs:74
Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Destroy(Object instance) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\ComponentActivator\AbstractComponentActivator.cs:87
Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.Release(Object instance) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Lifestyle\AbstractLifestyleManager.cs:64
Castle.MicroKernel.Handlers.DefaultHandler.ReleaseCore(Burden burden) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Handlers\DefaultHandler.cs:65
Castle.MicroKernel.Handlers.AbstractHandler.Release(Burden burden) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Handlers\AbstractHandler.cs:170
Castle.MicroKernel.Burden.Release() in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Burden.cs:119
Castle.MicroKernel.Lifestyle.Scoped.ScopeCache.<Dispose>b__0(Burden b) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Lifestyle\Scoped\ScopeCache.cs:65
Castle.Core.Internal.CollectionExtensions.ForEach(IEnumerable`1 items, Action`1 action) in d:\work\16de7b8c88ab14af\src\Castle.Core\Core\Internal\CollectionExtensions.cs:44
Castle.MicroKernel.Lifestyle.Scoped.ScopeCache.Dispose() in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Lifestyle\Scoped\ScopeCache.cs:65
Castle.MicroKernel.Lifestyle.Scoped.DefaultLifetimeScope.Dispose() in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Lifestyle\Scoped\DefaultLifetimeScope.cs:38
Castle.MicroKernel.Lifestyle.PerWebRequestLifestyleModule.Application_EndRequest(Object sender, EventArgs e) in c:\Downloads\Windsor-3.3\Windsor-3.3\src\Castle.Windsor\MicroKernel\Lifestyle\PerWebRequestLifestyleModule.cs:47
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +92
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165
The code that throws the exception is:
AbstractComponentActivator.ApplyConcerns(IEnumerable<IDecommissionConcern> steps, object instance)
DisposalConcern.Apply(ComponentModel model, object component)
When debugging I have noticed the following difference:
When service.Hello(); is called and the frameowrk throws a MessageSecurityException
then object component = {System.ServiceModel.Channels.ServiceChannelProxy}
in DisposalConcern.Apply(ComponentModel model, object component)
this throws the CommunicationObjectFaultedException
When service.Hello(); is called and I throw new Exception("test")
then object component = {System.Runtime.Remoting.Proxies.__TransparentProxy}
in DisposalConcern.Apply(ComponentModel model, object component)
this does not throw an exception
The service is registered as follows in the web application:
public class MeldingssystemServiceInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<IMeldingssystemService>()
.AsWcfClient(new DefaultClientModel(WcfEndpoint.FromConfiguration("MeldingssystemService")))
.LifeStyle.PerWebRequest);
}
}
I’m trying to figure out if this is a bug/limitation in Castle Windsor or a configuration error.
You could add abort statement on the OnDestroy event:
public class MeldingssystemServiceInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<IMeldingssystemService>()
.AsWcfClient(new DefaultClientModel(WcfEndpoint.FromConfiguration("MeldingssystemService")))
.LifeStyle.PerWebRequest.OnDestroy(service =>
{
var channel = (IClientChannel) service;
if (channel.State == CommunicationState.Faulted)
channel.Abort();
}));
}
}
try adding an abort statement:
try {
service.Hello();
}
catch (Exception e) {
service.abort();
log.Error("Service error", e);
}
See the following : http://www.codeproject.com/Articles/74129/The-Proper-Use-and-Disposal-of-WCF-Channels-or-Com
Good luck,
Marwijn.
The root cause of the error was a regression bug in the castle windsor wcf facility. The bug has been fixed in version 4.1.0 of the nuget package Castle.WcfIntegrationFacility.
The order of the cleanup statements has been changed, for details see https://github.com/castleproject/Windsor/issues/104

40400: Endpoint not found - Windows Service Bus

I am running on premise Windows Service Bus 1.0 and I am getting the exception MessaingEntityNotFoundException 40400: Endpoint not found.
Is this because the queue is not created? I cant see anywhere on the server where I can create queues (I'm using 2K8R2), when I run the Service Bus Configuration tool it only asks if I want to remove from the farm.
Do I need to add a queue, if so is there a gui or powershell script, or am I doing something else wrong?
Connection string in app.config
<appSettings>
<!-- Service Bus specific app setings for messaging connections -->
<add key="Microsoft.ServiceBus.ConnectionString" value="Endpoint=sb://sqldev1.domain.local/domaintest1;StsEndpoint=https://sqldev1.domain.local:9355/domain-test1;RuntimePort=9354;ManagementPort=9355" />
</appSettings>
Code is below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.ServiceBus;
using Microsoft.ServiceBus.Messaging;
using System.Threading.Tasks;
namespace WindowsServerEventBus
{
class Program
{
static void Main(string[] args)
{
MessagingFactory messageFactory = MessagingFactory.Create();
NamespaceManager namespaceManager = NamespaceManager.Create();
QueueClient myQueueClient = messageFactory.CreateQueueClient("WowWowWee");
BrokeredMessage sendMessage = new BrokeredMessage("Hello World!");
myQueueClient.Send(sendMessage);
BrokeredMessage receivedMessage = myQueueClient.Receive(TimeSpan.FromSeconds(5));
if (receivedMessage != null)
{
Console.WriteLine(string.Format("Message received: Body = {0}",
receivedMessage.GetBody<string>()));
receivedMessage.Complete();
}
messageFactory.Close();
Console.ReadLine();
}
}
}
Exception dump below:
Microsoft.ServiceBus.Messaging.MessagingEntityNotFoundException was unhandled
HResult=-2146233088
Message=40400: Endpoint not found..TrackingId:1271f18d-3fa7-4437-9f86-7276ff5909b4_Gsqldev1,TimeStamp:16/03/2013 19:05:33
Source=Microsoft.ServiceBus
IsTransient=false
StackTrace:
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnEndSend(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.OnSend(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at Microsoft.ServiceBus.Messaging.MessageSender.Send(TrackingContext trackingContext, IEnumerable`1 messages, TimeSpan timeout)
at Microsoft.ServiceBus.Messaging.MessageSender.Send(BrokeredMessage message)
at Microsoft.ServiceBus.Messaging.QueueClient.Send(BrokeredMessage message)
at WindowsServerEventBus.Program.Main(String[] args) in c:\Users\user\Downloads\EventStore-master\EventStore-master\src\WindowsServerEventBus\Program.cs:line 78
at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException: System.ServiceModel.FaultException
HResult=-2146233087
Message=40400: Endpoint not found..TrackingId:1271f18d-3fa7-4437-9f86-7276ff5909b4_Gsqldev1,TimeStamp:16/03/2013 19:05:33
Source=Microsoft.ServiceBus
Action=http://schemas.microsoft.com/servicebus/2010/08/protocol/Fault
StackTrace:
Server stack trace:
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.ThrowIfFaultMessage(Message wcfMessage)
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.HandleMessageReceived(IAsyncResult result)
Exception rethrown at [0]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.DuplexCorrelationAsyncResult.End(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.DuplexRequestBindingElement.DuplexRequestSessionChannel.EndRequest(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [1]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.RequestAsyncResult.<>c__DisplayClass17.<GetAsyncSteps>b__a(RequestAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [2]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Sbmp.RedirectBindingElement.RedirectContainerChannelFactory`1.RedirectContainerSessionChannel.EndRequest(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.RequestAsyncResult.<GetAsyncSteps>b__4(RequestAsyncResult thisPtr, IAsyncResult r)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [3]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Channels.ReconnectBindingElement.ReconnectChannelFactory`1.RequestSessionChannel.EndRequest(IAsyncResult result)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpTransactionalAsyncResult`1.<GetAsyncSteps>b__36(TIteratorAsyncResult thisPtr, IAsyncResult a)
at Microsoft.ServiceBus.Messaging.IteratorAsyncResult`1.StepCallback(IAsyncResult result)
Exception rethrown at [4]:
at Microsoft.ServiceBus.Common.AsyncResult.End[TAsyncResult](IAsyncResult result)
at Microsoft.ServiceBus.Common.AsyncResult`1.End(IAsyncResult asyncResult)
at Microsoft.ServiceBus.Messaging.Sbmp.SbmpMessageSender.EndSendCommand(IAsyncResult result)
InnerException:
You can create the queue in your code by using the NameSpaceManager.
namespaceManager.CreateQueue("WowWowWee");
If you are using NimbusAPI which creates Azure service bus topics automatically, a topic that is not subscribed to by is automatically deleted after 367 days because it is idle. To resolve this, restart the service, and it should restore any missing topics.

Categories