2010-01-05 2 views
4

NetTcpBinding을 사용하여 WcfService를 설정하려고합니다. 대용량 파일을 전송할 것이므로 전송 모드를 사용합니다. 나는 세션을 사용할 필요가, 나는 NetTcpBinding이 지원 읽었습니다,하지만 난처럼 전원을 켜 때스트리밍 및 세션 NetTcpBinding

System.InvalidOperationException : 계약이 세션이 필요하지만, 바인딩 '

SessionMode=SessionMode.Required 

나는 오류 NetTcpBinding '이 지원하지 않거나 올바르게 지원하도록 구성되지 않았습니다.

누구든지 NetTcpBinding을 세션에서 사용할 수 있도록하려면 어떻게해야합니까? 어떤 도움 :)

답변

11

에 대한 감사합니다 당신은 의심의 여지가이 문제를 해결했습니다 -

이 쥬발 로이에 의해 "프로그래밍 WCF 서비스"에 따르면 ...하지만 (내가 그랬던 것처럼) 그 건너 다른 사람을 위해 - 당신에게 SessionMode.Required가 구성된 계약으로 스트리밍을 사용할 수 없습니다. 243 페이지 참조

스트리밍과 함께 안정적인 메시징을 사용하는 NetTcpBinding도 사용할 수 없습니다.

이유에 대해 자세히 설명하지 않습니다.

한 가지 해결 방법은 세션 모드가 필요한 작업을 별도의 계약서로 분리하고 스트리밍 작업을 다른 세션으로 분할하는 것입니다. 그런 다음 비 스트리밍 인터페이스에서 RegisterSession (Guid mySessionId) 작업으로 전달되는 각 클라이언트의 고유 ID (클라이언트 응용 프로그램의 수명 동안 고유 한 GUID)를 구현합니다. 세션이 서버에서 생성되면 GUID, SessionContractImplemenation 쌍을 사전에 저장하는 세션 관리자 객체로 등록 할 수 있습니다.

스트리밍 계약 구현 (제공된 GUID를 사용하여 만든 세션 관리자를 통해) 스트리밍 계약 구현이 실시간 비 스트리밍 객체에 액세스 할 수 있도록 스트리밍 계약 작업 (동일한 GUID)에 param을 추가합니다.

세션 수명을 적절하게 관리해야합니다. Microsoft에서

...

Sessions and Streaming When you have a large amount of data to transfer, the streaming transfer mode in WCF is a feasible alternative to the default behavior of buffering and processing messages in memory in their entirety. You may get unexpected behavior when streaming calls with a session-based binding. All streaming calls are made through a single channel (the datagram channel) that does not support sessions even if the binding being used is configured to use sessions. If multiple clients make streaming calls to the same service object over a session-based binding, and the service object's concurrency mode is set to single and its instance context mode is set to PerSession, all calls must go through the datagram channel and so only one call is processed at a time. One or more clients may then time out. You can work around this issue by either setting the service object's InstanceContextMode to PerCall or Concurrency to multiple.

참고 : 하나의 "세션"을 사용할 수 있기 때문에
MaxConcurrentSessions이 경우에는 영향을주지 않습니다.

http://msdn.microsoft.com/en-us/library/ms733040.aspx