Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Indigo

Not receiving Faulted event from ServiceHost

 
 
Thread Tools Display Modes
Old 09-17-2007   #1 (permalink)
Stephen Sankey
Guest


 

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.
Old 09-18-2007   #2 (permalink)
Stephen Sankey
Guest


 

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.
 

Thread Tools
Display Modes









Vistax64.com 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 2005-2008

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 47 48 49 50