2012-05-10 42 views
1

嗨,receiveTimeout閒置後中斷通信信道?

我在IIS具有以下綁定配置託管的WCF服務:

<binding name="netTcpRegular" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:00:20" sendTimeout="00:20:00" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647"> 
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
      <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/> 
      <security mode="None"> 
      <transport clientCredentialType="None" /> 
      </security> 
     </binding> 

當客戶端(即佔用信道開放)已經登錄到WCF服務頻道會在20秒後拋出一個錯誤的例外,我沒有做任何事情,甚至沒有與服務交流?所以在20秒鐘不活動之後,通信將失敗。

receiveTimeout應該只會影響正在進行調用的權利?那麼,它什麼時候什麼也不做,只能讓渠道開放並準備好接聽服務電話,它怎麼會這樣呢?

編輯:

通過使用WCF登錄我得到這個異常:

<DataItem> 
<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"> 
<TraceIdentifier>http://msdn.microsoft.com/sv-SE/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier> 
<Description>Throwing an exception.</Description> 
<AppDomain>/LM/W3SVC/1/ROOT/MyTest-1-129811288584315020</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.PreReadConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.TracingConnection.EndRead() 
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() 
at System.ServiceModel.Channels.TracingConnection.WaitCallback(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.PreReadConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.TracingConnection.EndRead() 
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() 
at System.ServiceModel.Channels.TracingConnection.WaitCallback(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> 

<TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Error"> 
<TraceIdentifier>http://msdn.microsoft.com/sv-SE/library/System.ServiceModel.Diagnostics.ThrowingException.aspx</TraceIdentifier> 
<Description>Throwing an exception.</Description> 
<AppDomain>/LM/W3SVC/1/ROOT/MyTest-1-129811288584315020</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.PreReadConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
at System.ServiceModel.Channels.TracingConnection.EndRead() 
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
</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 --- 
    at System.ServiceModel.Channels.SocketConnection.EndRead() 
    at System.ServiceModel.Channels.PreReadConnection.EndRead() 
    at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
    at System.ServiceModel.Channels.DelegatingConnection.EndRead() 
    at System.ServiceModel.Channels.TracingConnection.EndRead() 
    at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state)</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.SessionConnectionReader.GetPendingMessage() 
at System.ServiceModel.Channels.SessionConnectionReader.EndReceive() 
at System.ServiceModel.Channels.SynchronizedMessageSource.ReceiveAsyncResult.OnReceiveComplete(Object state) 
at System.ServiceModel.Channels.SessionConnectionReader.OnAsyncReadComplete(Object state) 
at System.ServiceModel.Channels.TracingConnection.TracingConnectionState.ExecuteCallback() 
at System.ServiceModel.Channels.TracingConnection.WaitCallback(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> 

編輯:

客戶方綁定:

<binding name="NetTcpBinding_IMyClientServiceRegular" closeTimeout="00:01:00" openTimeout="00:00:30" receiveTimeout="00:00:30" sendTimeout="00:00:30" transactionFlow="false" transferMode="Buffered" transactionProtocol="OleTransactions" hostNameComparisonMode="StrongWildcard" listenBacklog="10" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxConnections="10" maxReceivedMessageSize="2147483647"> 
    <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647"/> 
    <reliableSession ordered="true" inactivityTimeout="infinite" enabled="false"/> 
    <security mode="None"> 
    <transport clientCredentialType="None"/> 
    </security> 
</binding> 
+0

你的客戶端綁定配置是什麼? – SliverNinja

+0

我已更新我的帖子。 – Banshee

+0

[this SO post]可能的重複(http://stackoverflow.com/q/6042539/175679) – SliverNinja

回答

2

您錯過了meaning of ReceiveTimeout。這是「連接可以保持非活動狀態的時間間隔,在這段時間內,沒有收到任何應用程序消息,而是在它被刪除之前」。要將此擴展到無窮大,您需要enable reliable sessions。希望這可以清除它。

編輯: Here進一步的描述,我覺得你是以後的財產的SendTimeout

+0

p.s.對於recievetimeout屬性,默認爲10分鐘 – ldgorman

+0

可以將ReceiveTimout設置爲無限,這是我之前使用的設置,但它感覺不對。如果我需要長時間的會話,那麼這是我應該使用的唯一設置。 – Banshee

+0

@SnowJim是的,這是您需要使會話「持久」的設置 – ldgorman

0

接收超時是多長時間等待要接收的所有數據。

當chanel打開時,時間開始運行,它不檢測您發送的第一個字節,然後啓動計時器。

它有點像出租車,當你把它拉下來時啓動儀表,而不是當你進入。