我們正在使用中間層IIS上託管的WCF服務並使用WPF客戶端。 我們在生產日誌中看到這些錯誤。從谷歌我被指向這裏的鏈接http://kennyw.com/indigo/150明確表示,這個錯誤是與MaxConcurrentSessions有關。WCF代理連接打開導致錯誤
下面的生產日誌詳細信息表明,當WPF客戶端試圖使用ICommunicationObject.Open()打開WCF代理連接時發生錯誤() 我們的生產系統上的這個錯誤發生得非常頻繁,但我無法重現此錯誤我的本地設置。我試圖將MaxConcurrentSessions更改爲1,然後打開WPF應用程序的5個實例,在WPF應用程序的默認儀表板上每運行一分鐘,都會運行一個計時器,試圖獲取數據,但仍然無法重現此錯誤。
我的問題是真的什麼時候發生這種錯誤,從上面的鏈接說它發生這種情況時,服務器是緊張的,但在我的測試案例上面它應該已經加載。我也需要能夠重現這個甚至試圖修復。
任何想法,如果我在正確的道路上,是MaxConcurrentSessions正確的地方看看,我該如何模擬本地。請幫忙。
2/16/2012 4:10:40 PM:Information:Exception in the ServiceCall constructor: 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 '00:00:59.9687730'. --->System.Net.Sockets.SocketException:
An existing connection was forcibly closed by the remote host at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags) at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
--- End of inner exception stack trace ---
Server stack trace:
at System.ServiceModel.Channels.SocketConnection.ReadCore(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout, Boolean closing)
at System.ServiceModel.Channels.SocketConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.DelegatingConnection.Read(Byte[] buffer, Int32 offset, Int32 size, TimeSpan timeout)
at System.ServiceModel.Channels.ConnectionUpgradeHelper.InitiateUpgrade (StreamUpgradeInitiator upgradeInitiator, IConnection& connection, ClientFramingDecoder decoder, IDefaultCommunicationTimeouts defaultTimeouts, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreamble(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConnectionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& timeoutHelper)
at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(TimeSpan timeout)
at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.ServiceChannel.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
我們使用的是使用塊爲每個連接重寫的Idispose刪除對象,這是一個乾淨的方式來做到這一點。 -------------------------------- public void TryCloseOrAbort(ICommunicationObject obj){if(obj!= null){if( obj.State!= CommunicationState.Faulted && obj.State!= CommunicationState.Closed){try {obj.Close(); } catch(CommunicationObjectFaultedException){obj.Abort(); } catch(TimeoutException){obj.Abort(); } catch(Exception){obj.Abort(); throw;}} else obj.Abort();}} – lloydom 2012-03-21 12:59:28
我在代碼中看到的唯一有點奇怪的地方是它可以在一個obj實例上調用Abort有obj。狀態== CommunicationState.Closed。請嘗試檢查[ICommunicationObject文檔](http://msdn.microsoft.com/zh-cn/library/ms789041.aspx)以查看是否可能導致處理過程中出現問題。 – 2012-03-21 13:29:39
感謝您的回覆sixto,鏈接說,關閉通信狀態值調用中止不會導致問題「如果當前狀態爲」關閉「或者對象已在」之前終止「,則Abort()方法不會執行任何操作,因此它不應該導致我看到的這個問題。嗯,你認爲這個錯誤只是因爲使用塊嗎? -------------------------------------------------- -Using(var svc = new ServiceCall(endpointName)){serviceCallType = svc.GetType(); //調用調用者實現的服務調用serviceCallBody(svc); } –
lloydom
2012-03-22 08:36:23