2009-11-12 3 views
5

실제 WCF 응용 프로그램에서 가지고있는 문제를 재현하는 샘플 WCF 프로젝트가 있습니다. 당신은 코드와 설정 파일의 시간 제한 설정에 accoding의 내 샘플 WCF 응용 프로그램 here통신 개체가 통신을 위해 중단 되었기 때문에 사용할 수 없습니다.

의 소스 코드를 다운로드 할 수 있습니다, 나는 appening 무엇인지 이해하지 않습니다 당신이 전달하는 것처럼

**** Server exception : System.ServiceModel.CommunicationObjectAbortedException: 

The communication object, System.ServiceModel.Security.SecuritySessionServerSettings+SecurityReplySessionChannel, cannot be used for communication because it 
has been Aborted. 

    at System.ServiceModel.Channels.CommunicationObject.ThrowIfClosedOrNotOpen() 
    at System.ServiceModel.Security.SecuritySessionServerSettings.ServerSecuritySessionChannel.SecureApplicationMessage(Message& message, TimeSpan timeout, SecurityProtocolCorrelationState correlationState) 
    at System.ServiceModel.Security.SecuritySessionServerSettings.SecuritySessionRequestContext.OnReply(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestContextBase.Reply(Message message, TimeSpan timeout) 
    at System.ServiceModel.Channels.RequestContextBase.Reply(Message message) 
    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.Reply(MessageRpc& rpc) 

**** client exception : : System.ServiceModel.Security.MessageSecurityException: An unsecured or incorrectly secured fault was received from the other party. See the inner FaultException for the fault code and detail. ---> System.ServiceModel.FaultException: The message could not be processed. This is most likely because the action 'http://schemas.xmlsoap.org/ws/2005/02/trust/RST/SCT/Cancel' is incorrect or because the message contains an invalid or expired security context token or because there is a mismatch between bindings. The security context token would be invalid if the service aborted the channel due to inactivity. To prevent the service from aborting idle sessions prematurely increase the Receive timeout on the service endpoint's binding. 
    --- End of inner exception stack trace --- 

Server stack trace: 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.ProcessRequestContext(RequestContext requestContext, TimeSpan timeout, SecurityProtocolCorrelationState correlationState) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.ReceiveInternal(TimeSpan timeout, SecurityProtocolCorrelationState correlationState) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.SecurityRequestSessionChannel.CloseOutputSession(TimeSpan timeout) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.CloseSession(TimeSpan timeout, Boolean& wasAborted) 
    at System.ServiceModel.Security.SecuritySessionClientSettings`1.ClientSecuritySessionChannel.OnClose(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) 
    at System.ServiceModel.Channels.ServiceChannel.OnClose(TimeSpan timeout) 
    at System.ServiceModel.Channels.CommunicationObject.Close(TimeSpan timeout) 

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 System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout) 
    at System.ServiceModel.ClientBase`1.System.ServiceModel.ICommunicationObject.Close(TimeSpan timeout) 
    at System.ServiceModel.ClientBase`1.Close() 
    at System.ServiceModel.ClientBase`1.System.IDisposable.Dispose() 
    at WindowsFormsApplication1.Program.Main() in C:\Users\sdoucet\Documents\Visual Studio 2008\Projects\TestWCFLongExecution\WindowsFormsApplication1\Program.cs:line 25 

답변

1

가 보이는 예외를 클라이언트에 다시 보냅니다. WCF는 일반적인 예외를 좋아하지 않으며 오류가 발생하면 fauls 또는 FaultException을 원합니다. 예외가 반환 된 후 채널은 오류가 발생한 상태이므로 다시 사용할 수 없습니다. FaultException 후에도 채널을 사용할 수 있습니다.

+0

맞아요,하지만 예외는 제 코드에 의해 발생하지 않습니다. WCF 인프라에 의해 throw됩니다. 나는이 예외가 왜 던져지며 어떻게 피하는지를 알지 못한다. 내 서비스가 10 분 동안 실행되고 있지만 타임 아웃 세트에 따르면 예외를 이해하지 못한다는 것을 알고 있습니다. – Sebastien

+2

먼저 할 일은 서비스에서 전체 추적을 사용 가능하게하는 것입니다. 이것은 종종 원래의 문제가 무엇인지에 대한 많은 정보를 줄 것입니다. – Maurice

6

서비스를 호스팅하는 응용 프로그램 풀이 최대 작업자 프로세스가 1보다 크게 구성 되었기 때문에 비슷한 문제가있었습니다. 중단 또는 닫기 호출이 성공한 경우 해당 서비스 인스턴스를 처리 한 서비스 인스턴스로 라우팅해야합니다 원래 요청.

+1

게시 해 주셔서 감사합니다. 고객 스테이징 환경에서 똑같은 문제가 발생했습니다. 그들의 개발자 중 한 명은 'Maximum Worker Processes'를 5로 설정하여 이러한 예외를 발생 시켰습니다. 우리는 wsfederationhttpbinding을 사용하고 보안 토큰 서비스 (Security Token Service, STS)를 제 위치에 두었습니다. 예외가 더 혼란 스럽습니다. 토큰이 유효하지 않다는 것을 암시합니다. 사실 요청은 때로는 잘못된 작업자 프로세스로 전달되는 경우가있었습니다. –

+0

동일한 문제가 발생했으며 메시지 보안과 함께 wshttpbinding을 사용하고있었습니다. 웹 서비스 기계 앞에서 Netscalar로드 밸런서를 사용하면 트리 오징이 훨씬 더 어려워졌습니다. 처음에는 LB가 끈적 거리는 세션을 유지하지 못하고 있다고 생각하고 LB를 가져 와서 문제를 해결할 수 있는지 알아보기 위해 노력했습니다. 그러나 최대 작업자 프로세스 설정이 1보다 큰 것으로 나타났습니다. –

2

나는 wcf 서비스 비동기 호출을 한 것과 비슷한 문제가있었습니다. async_completed 메서드에서 결과를받은 후 예외가 발생했습니다.

는 "예외는 결과가 유효하고, 운전 중에 발생한 예외의 InnerException을 확인하십시오."

의 InnerException :
"가 중단되었습니다 때문에 통신 개체 통신에 사용할 수 없습니다"

많은 노력 끝에 해결책을 찾았지만 async_completed 메소드를 던지지 않고 예외를 잡았습니다. (즉, try/catch 구현). 나는 정확한 문제가 무엇인지 이해하지 못했지만 어떻게 든 통신 채널은 깨졌습니다.

나는 아직도 나는 이것이 올바른 접근 방식이라고 확신 아니지만, 연산 결과 내 시나리오에 따라 내가 furtherly 아무것도하고 있지 않다 다음 링크

http://geekswithblogs.net/SoftwareDoneRight/archive/2008/05/23/clean-up-wcf-clients--the-right-way.aspx

에서 위의 approch을 시도했다. 따라서 예외를 포착하고 서비스를 중지합니다.

관련 문제