Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Indigo

Vista - Not receiving Faulted event from ServiceHost

 
 
Old 09-17-2007   #1 (permalink)
Stephen Sankey


 
 

Not receiving Faulted event from ServiceHost

I'm trying to implement reliable messaging so I can detect communication
failures between the client and the server.

I would like to be notified of comms failures on the client side and the
server side. I've successfully hooked up the Faulted event on the client side
using my DuplexChannel and this seems to work quite nicely. If I kill my
server (hosted as a windows service), the client gets the Faulted event after
my InactivityTimeout of 3 seconds kick in.
However, on the server side I'm unable to get the Faulted event raised by
the ServiceHost. If I kill my client I never see the Faulted event raised by
my ServiceHost.

Here is the snippet of service code for setting up the reliable tcp binding:


_serviceHostKV = new ServiceHost(typeof(KVImaging));

NetTcpBinding reliabletcpBinding = new NetTcpBinding();

reliabletcpBinding.Security.Mode = SecurityMode.None;

reliabletcpBinding.SendTimeout = ts;
// Select a receive timeout of TimeSpan.MaxValue which effectively
gives an infinite timeout.
// NB. Rather confusingly this is not the time it takes to receive a
call, but is the timeout interval
// between received calls
reliabletcpBinding.ReceiveTimeout = TimeSpan.MaxValue;

// Switch on reliable sessions
reliabletcpBinding.ReliableSession.Enabled = true;

// Timeout on arbitary value of 3 seconds
reliabletcpBinding.ReliableSession.InactivityTimeout =
TimeSpan.FromSeconds(3);

//Add the endpoint

_serviceHostKV.AddServiceEndpoint(typeof(IdaqProtocolCom.IVolumeView),
reliabletcpBinding, iDaqServerAddressKV);

// Hook up the faulted event for the kV service
_serviceHostKV.Faulted += new EventHandler(ChannelFaulted);

// Open the ServiceHosts
_serviceHostKV.Open();


I've configured a diagnostics trace lister into the service and it looks
like the Inactivity Timeout is detected, please see the following:


<E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
<System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
<EventID>131075</EventID>
<Type>3</Type>
<SubType Name="Error">0</SubType>
<Level>2</Level>
<TimeCreated SystemTime="2007-09-17T12:35:14.3994114Z" />
<Source Name="System.ServiceModel" />
<Correlation ActivityID="{120b8c7c-5a59-4122-a1c0-812954a341a5}" />
<Execution ProcessName="XXXXXX.YYYYYY.IdaqServer" ProcessID="964"
ThreadID="6" />
<Channel />
<Computer>CD04109</Computer>
</System>
<ApplicationData>
<TraceData>
<DataItem>
<TraceRecord
xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"
Severity="Error">
<TraceIdentifier>http://msdn.microsoft.com/en-GB/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
<Description>Throwing an exception.</Description>
<AppDomain>XXXXXX.YYYYYY.IdaqServer.exe</AppDomain>
<Exception>
<ExceptionType>System.ServiceModel.CommunicationException,
System.ServiceModel, Version=3.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089</ExceptionType>
<Message>The inactivity timeout of (00:00:03) has been exceeded.</Message>
<StackTrace>
at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at
System.ServiceModel.Channels.InputQueue`1.AsyncQueueReader.End(IAsyncResult
result, T& value)
at System.ServiceModel.Channels.InputQueue`1.EndDequeue(IAsyncResult result,
T& value)
at System.ServiceModel.Channels.DuplexChannel.EndTryReceive(IAsyncResult
result, Message& message)
at
System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult
result, RequestContext& requestContext)
at
System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
at
System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult
result)
at
System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
at
System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
at System.ServiceModel.Channels.InputQueue`1.AsyncQueueReader.Set(Item item)
at System.ServiceModel.Channels.InputQueue`1.Shutdown(CommunicationObject
communicationObject)
at System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnClosing()
at System.ServiceModel.Channels.CommunicationObject.Abort()
at System.ServiceModel.Dispatcher.DuplexChannelBinder.Abort()
at System.ServiceModel.Channels.ServiceChannel.OnAbort()
at System.ServiceModel.Channels.CommunicationObject.Abort()
at System.ServiceModel.Channels.ServiceChannel.OnInnerChannelFaulted(Object
sender, EventArgs e)
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.ServiceModel.Channels.CommunicationObject.OnFaulted()
at System.ServiceModel.Channels.ServerReliableDuplexSessionChannel.OnFaulted()
at System.ServiceModel.Channels.CommunicationObject.Fault()
at System.ServiceModel.Channels.CommunicationObject.Fault(Exception exception)
at
System.ServiceModel.Channels.ChannelReliableSession.OnLocalFault(Exception e,
Message faultMessage, RequestContext context)
at
System.ServiceModel.Channels.ChannelReliableSession.OnLocalFault(Exception e,
WsrmFault fault, RequestContext context)
at
System.ServiceModel.Channels.ChannelReliableSession.OnInactivityElapsed(Object state)
at System.ServiceModel.Channels.InterruptibleTimer.OnTimerElapsed()
at System.ServiceModel.Channels.InterruptibleTimer.OnTimerElapsed(Object
state)
at System.ServiceModel.Channels.IOThreadScheduler.WorkItem.Invoke()
at System.ServiceModel.Channels.IOThreadScheduler.ProcessCallbacks()
at System.ServiceModel.Channels.IOThreadScheduler.CompletionCallback(Object
state)
at
System.ServiceModel.Channels.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at
System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
</StackTrace>
<ExceptionString>System.ServiceModel.CommunicationException: The inactivity
timeout of (00:00:03) has been exceeded.</ExceptionString>
</Exception>
</TraceRecord>
</DataItem>
</TraceData>
</ApplicationData>
</E2ETraceEvent>


Any help would be much appreciated,

Regards,
Stephen.

My System SpecsSystem Spec
Old 09-18-2007   #2 (permalink)
Stephen Sankey


 
 

RE: Not receiving Faulted event from ServiceHost

I seem to have fixed this bug by also hooking into the channel on the Service
side using this code :

OperationContext.Current.Channel.Faulted += new
EventHandler(ChannelFaulted);


Seems obvious enough, but I've been hooking up to the ServiceHost's Faulted
event. I'm now not sure as to under what circumstances, if ever, the
ServiceHost will raise it's Faulted event ?

"Stephen Sankey" wrote:
Quote:

> I'm trying to implement reliable messaging so I can detect communication
> failures between the client and the server.
>
> I would like to be notified of comms failures on the client side and the
> server side. I've successfully hooked up the Faulted event on the client side
> using my DuplexChannel and this seems to work quite nicely. If I kill my
> server (hosted as a windows service), the client gets the Faulted event after
> my InactivityTimeout of 3 seconds kick in.
> However, on the server side I'm unable to get the Faulted event raised by
> the ServiceHost. If I kill my client I never see the Faulted event raised by
> my ServiceHost.
>
> Here is the snippet of service code for setting up the reliable tcp binding:
>
>
> _serviceHostKV = new ServiceHost(typeof(KVImaging));
>
> NetTcpBinding reliabletcpBinding = new NetTcpBinding();
>
> reliabletcpBinding.Security.Mode = SecurityMode.None;
>
> reliabletcpBinding.SendTimeout = ts;
> // Select a receive timeout of TimeSpan.MaxValue which effectively
> gives an infinite timeout.
> // NB. Rather confusingly this is not the time it takes to receive a
> call, but is the timeout interval
> // between received calls
> reliabletcpBinding.ReceiveTimeout = TimeSpan.MaxValue;
>
> // Switch on reliable sessions
> reliabletcpBinding.ReliableSession.Enabled = true;
>
> // Timeout on arbitary value of 3 seconds
> reliabletcpBinding.ReliableSession.InactivityTimeout =
> TimeSpan.FromSeconds(3);
>
> //Add the endpoint
>
> _serviceHostKV.AddServiceEndpoint(typeof(IdaqProtocolCom.IVolumeView),
> reliabletcpBinding, iDaqServerAddressKV);
>
> // Hook up the faulted event for the kV service
> _serviceHostKV.Faulted += new EventHandler(ChannelFaulted);
>
> // Open the ServiceHosts
> _serviceHostKV.Open();
>
>
> I've configured a diagnostics trace lister into the service and it looks
> like the Inactivity Timeout is detected, please see the following:
>
>
> <E2ETraceEvent xmlns="http://schemas.microsoft.com/2004/06/E2ETraceEvent">
> <System xmlns="http://schemas.microsoft.com/2004/06/windows/eventlog/system">
> <EventID>131075</EventID>
> <Type>3</Type>
> <SubType Name="Error">0</SubType>
> <Level>2</Level>
> <TimeCreated SystemTime="2007-09-17T12:35:14.3994114Z" />
> <Source Name="System.ServiceModel" />
> <Correlation ActivityID="{120b8c7c-5a59-4122-a1c0-812954a341a5}" />
> <Execution ProcessName="XXXXXX.YYYYYY.IdaqServer" ProcessID="964"
> ThreadID="6" />
> <Channel />
> <Computer>CD04109</Computer>
> </System>
> <ApplicationData>
> <TraceData>
> <DataItem>
> <TraceRecord
> xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord"
> Severity="Error">
> <TraceIdentifier>http://msdn.microsoft.com/en-GB/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier>
> <Description>Throwing an exception.</Description>
> <AppDomain>XXXXXX.YYYYYY.IdaqServer.exe</AppDomain>
> <Exception>
> <ExceptionType>System.ServiceModel.CommunicationException,
> System.ServiceModel, Version=3.0.0.0, Culture=neutral,
> PublicKeyToken=b77a5c561934e089</ExceptionType>
> <Message>The inactivity timeout of (00:00:03) has been exceeded.</Message>
> <StackTrace>
> at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
> at
> System.ServiceModel.Channels.InputQueue`1.AsyncQueueReader.End(IAsyncResult
> result, T& value)
> at System.ServiceModel.Channels.InputQueue`1.EndDequeue(IAsyncResult result,
> T& value)
> at System.ServiceModel.Channels.DuplexChannel.EndTryReceive(IAsyncResult
> result, Message& message)
> at
> System.ServiceModel.Dispatcher.DuplexChannelBinder.EndTryReceive(IAsyncResult
> result, RequestContext& requestContext)
> at
> System.ServiceModel.Dispatcher.ErrorHandlingReceiver.EndTryReceive(IAsyncResult result, RequestContext& requestContext)
> at
> System.ServiceModel.Dispatcher.ChannelHandler.AsyncMessagePump(IAsyncResult
> result)
> at
> System.ServiceModel.Dispatcher.ChannelHandler.OnAsyncReceiveComplete(IAsyncResult result)
> at
> System.ServiceModel.Diagnostics.Utility.AsyncThunk.UnhandledExceptionFrame(IAsyncResult result)
> at System.ServiceModel.AsyncResult.Complete(Boolean completedSynchronously)
> at System.ServiceModel.Channels.InputQueue`1.AsyncQueueReader.Set(Item item)
> at System.ServiceModel.Channels.InputQueue`1.Shutdown(CommunicationObject
> communicationObject)
> at System.ServiceModel.Channels.ReliableDuplexSessionChannel.OnClosing()
> at System.ServiceModel.Channels.CommunicationObject.Abort()
> at System.ServiceModel.Dispatcher.DuplexChannelBinder.Abort()
> at System.ServiceModel.Channels.ServiceChannel.OnAbort()
> at System.ServiceModel.Channels.CommunicationObject.Abort()
> at System.ServiceModel.Channels.ServiceChannel.OnInnerChannelFaulted(Object
> sender, EventArgs e)
> at System.EventHandler.Invoke(Object sender, EventArgs e)
> at System.ServiceModel.Channels.CommunicationObject.OnFaulted()
> at System.ServiceModel.Channels.ServerReliableDuplexSessionChannel.OnFaulted()
> at System.ServiceModel.Channels.CommunicationObject.Fault()
> at System.ServiceModel.Channels.CommunicationObject.Fault(Exception exception)
> at
> System.ServiceModel.Channels.ChannelReliableSession.OnLocalFault(Exception e,
> Message faultMessage, RequestContext context)
> at
> System.ServiceModel.Channels.ChannelReliableSession.OnLocalFault(Exception e,
> WsrmFault fault, RequestContext context)
> at
> System.ServiceModel.Channels.ChannelReliableSession.OnInactivityElapsed(Object state)
> at System.ServiceModel.Channels.InterruptibleTimer.OnTimerElapsed()
> at System.ServiceModel.Channels.InterruptibleTimer.OnTimerElapsed(Object
> state)
> at System.ServiceModel.Channels.IOThreadScheduler.WorkItem.Invoke()
> at System.ServiceModel.Channels.IOThreadScheduler.ProcessCallbacks()
> at System.ServiceModel.Channels.IOThreadScheduler.CompletionCallback(Object
> state)
> at
> System.ServiceModel.Channels.IOThreadScheduler.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
> at
> System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
> at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32
> errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)
> </StackTrace>
> <ExceptionString>System.ServiceModel.CommunicationException: The inactivity
> timeout of (00:00:03) has been exceeded.</ExceptionString>
> </Exception>
> </TraceRecord>
> </DataItem>
> </TraceData>
> </ApplicationData>
> </E2ETraceEvent>
>
>
> Any help would be much appreciated,
>
> Regards,
> Stephen.
My System SpecsSystem Spec
 

Thread Tools



Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46