2011-09-30 6 views
8

Sto utilizzando il servizio WCF nell'applicazione client-server e sto riscontrando un errore successivo durante la comunicazione tra server e client.CommunicationObjectAbortedException nel canale di servizio WCF durante il caricamento di più dati

Error Message =>> System.ServiceModel.CommunicationObjectAbortedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it has been Aborted. 

Server stack trace: 
    at System.ServiceModel.Channels.CommunicationObject.ThrowIfDisposedOrNotOpen() 
    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 ServiceLib.ServiceCallbackInterfaces.IHostServiceCallback.SendEventAndStatus(String message, Boolean isBackupGenerated) 
    at ServiceLib.Services.DriversService.objDriver_EventReceived(Object sender, EventReceivedEventArgs e) 

scenario applicativo: client sta ottenendo i dati dal server tramite servizio WCF e utilizzare nettcp vincolante. Il server è connesso al dispositivo reale e genera 20-30 eventi ogni secondo. Gli eventi generati vengono inviati come messaggi di stringa a tutti i client connessi tramite l'interfaccia di callback di WCF. Funziona bene se il client non ha alcun carico di processo (basta ricevere eventi e display). Ma dà errore quando eseguiamo qualche processo di caricamento sul lato client e occupato per un po 'di tempo.

Nota: Avevo già impostato il massimo di tutti i timeout nel binding nettcp come indicato di seguito, ma il problema non è ancora risolto.

NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None); 
       tcpBinding.MaxBufferPoolSize = 2147483647; 
       tcpBinding.MaxReceivedMessageSize = 2147483647; 
       tcpBinding.MaxBufferSize = 2147483647; 
       tcpBinding.ReaderQuotas.MaxStringContentLength = 2147483647; 
       tcpBinding.ReaderQuotas.MaxDepth = 2147483647; 
       tcpBinding.ReaderQuotas.MaxBytesPerRead = 2147483647; 
       tcpBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647; 
       tcpBinding.ReaderQuotas.MaxArrayLength = 2147483647; 
       tcpBinding.SendTimeout = TimeSpan.MaxValue; 
       tcpBinding.ReceiveTimeout = TimeSpan.MaxValue; 
       tcpBinding.ReliableSession.InactivityTimeout = TimeSpan.MaxValue; 

Please guide me ci sono altre impostazioni necessarie relative al canale di comunicazione o al binding?

UPDATE: errore lanciati da SVC tracciante:

<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="2011-09-30T08:37:01.5691715Z" /> 
<Source Name="System.ServiceModel" /> 
<Correlation ActivityID="{00000000-0000-0000-0000-000000000000}" /> 
<Execution ProcessName="ServerUtility" ProcessID="2396" ThreadID="5" /> 
<Channel /> 
<Computer>TEST</Computer> 
</System> 
<ApplicationData> 
<TraceData> 
<DataItem> 
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"> 
<TraceIdentifier>http://msdn.microsoft.com/it-IT/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier> 
<Description>Throwing an exception.</Description> 
<AppDomain>ServerUtility.exe</AppDomain> 
<Exception> 
<ExceptionType>System.ServiceModel.CommunicationException, System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType> 
<Message>The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '10675199.02:48:05.4775807'.</Message> 
<StackTrace> 
at System.ServiceModel.Channels.SocketConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
at System.ServiceModel.Channels.SocketConnection.FinishRead() 
at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead) 
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) 
</StackTrace> 
<ExceptionString>System.ServiceModel.CommunicationException: The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '10675199.02:48:05.4775807'. ---&gt; System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host 
    --- End of inner exception stack trace ---</ExceptionString> 
<InnerException> 
<ExceptionType>System.Net.Sockets.SocketException, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</ExceptionType> 
<Message>An existing connection was forcibly closed by the remote host</Message> 
<StackTrace> 
at System.ServiceModel.Channels.SocketConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
at System.ServiceModel.Channels.SocketConnection.FinishRead() 
at System.ServiceModel.Channels.SocketConnection.AsyncReadCallback(Boolean haveResult, Int32 error, Int32 bytesRead) 
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) 
</StackTrace> 
<ExceptionString>System.Net.Sockets.SocketException (0x80004005): An existing connection was forcibly closed by the remote host</ExceptionString> 
<NativeErrorCode>2746</NativeErrorCode> 
</InnerException> 
</Exception> 
</TraceRecord> 
</DataItem> 
</TraceData> 
<System.Diagnostics xmlns="http://schemas.microsoft.com/2004/08/System.Diagnostics"> 
<LogicalOperationStack></LogicalOperationStack> 
<Timestamp>4730654290080</Timestamp> 
</System.Diagnostics> 
</ApplicationData> 
</E2ETraceEvent> 
+0

Verificare se il servizio sta generando eccezioni: eccezioni non gestite guastano il canale; potrebbe non essere un problema vincolante. – Tim

+1

Cosa ha detto @Tim; per fare ciò utilizzare il Service Trace Viewer, http://msdn.microsoft.com/en-us/library/ms732023.aspx –

+0

@JeremyMcGee: Non ho molta idea su come utilizzare Service Trace Viewer. Puoi per favore guidarmi? –

risposta

4

Come lei ha ricordato nella sua interrogazione, quando si avranno tutti i timeout di massima. Quindi secondo la mia opinione, ci dovrebbe essere un problema in InstanceContextMode che hai definito. Quale modalità hai definito nel tuo servizio? PerSession, PerCall o Single. Potrebbe esserci PerCall definito e che chiama il servizio dallo stesso oggetto (oggetto di servizio dichiarato globalmente), quindi è possibile che il canale entri in stato di errore o che la connessione sia disconnessa.

Quindi, se è stata definita la modalità PerSession, utilizzare un oggetto singolo (dichiarato globalmente) dal lato client per ottenere i dati dal servizio. Se hai definito l'opzione PerCall, crea ogni volta un nuovo oggetto.

Spero che questo aiuto a voi. Non esitate a chiedere qualsiasi dubbio ...

+0

Ho più servizi, un servizio principale chiamato HostService ha la modalità PerSession e tutti gli altri hanno la modalità PerCall. Nel servizio principale sto mantenendo l'elenco dei client connessi nella tabella di hash statica perché ho bisogno di inviare eventi a tutti i client utilizzando il metodo di callback. Quindi sto memorizzando l'oggetto conext di tutti i client collegati in quella lista. Al client sto facendo ogni volta un nuovo oggetto per chiamare il servizio. –

+0

Puoi descrivere come si invia la notifica dell'evento a tutti i clienti? Voglio dire puoi pubblicare un codice per questo. Un'altra cosa è quando si invia la notifica dell'evento ai client, in quel momento si chiama un altro servizio che ha la modalità PerCall? – Chief

+0

Come ti ho detto prima, sto inviando notifiche di eventi usando il metodo callback e sì quando cambio modalità di lavoro (supervisore, setup, offline) nella mia applicazione client, sto chiamando EventLogService per salvare i dati della modalità di lavoro, quindi verrà mostrato a tutti client connessi come notifica dal server. –

Problemi correlati