성태의 닷넷 이야기
홈 주인
모아 놓은 자료
프로그래밍
질문/답변
사용자 관리
사용자
메뉴
아티클
외부 아티클
유용한 코드
온라인 기능
MathJax 입력기
최근 덧글
[정성태] Java - How to use the Foreign Funct...
[정성태] 제가 큰 실수를 했군요. ^^; Delegate를 통한 Bein...
[정성태] Working with Rust Libraries from C#...
[정성태] Detecting blocking calls using asyn...
[정성태] 아쉽게도, 커뮤니티는 아니고 개인 블로그입니다. ^^
[정성태] 질문이 잘 이해가 안 됩니다. 우선, 해당 소스코드에서 ILis...
[양승조
] var대신 dinamic으로 선언해서 해결은 했습니다. 맞는 해...
[양승조
] 또 막혔습니다. ㅠㅠ var list = props[i].Ge...
[양승조
] 아. 감사합니다. 어제는 안됐던것 같은데....정신을 차려야겠네...
[정성태] "props[i].GetValue(props[i])" 코드에서 ...
글쓰기
제목
이름
암호
전자우편
HTML
홈페이지
유형
제니퍼 .NET
닷넷
COM 개체 관련
스크립트
VC++
VS.NET IDE
Windows
Team Foundation Server
디버깅 기술
오류 유형
개발 환경 구성
웹
기타
Linux
Java
DDK
Math
Phone
Graphics
사물인터넷
부모글 보이기/감추기
내용
<div style='display: inline'> <h1 style='font-family: Malgun Gothic, Consolas; font-size: 20pt; color: #006699; text-align: center; font-weight: bold'>wsDualHttpBinding + Windows Server 2003인 경우 발생하는 오류</h1> <p> WSDualHttpBinding 설정의 WCF 서비스를 윈도우 서버 2003 x86 IIS 6.0에서 호스팅하는 경우 ServerTooBusyException, CommunicationObjectFaultedException이 발생할 수 있습니다.<br /> <br /> 테스트를 위해 웹 프로젝트를 하나 만들고 간단하게 svc 서비스를 추가합니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > // 인터페이스 정의 using System.ServiceModel; namespace WebApplication1 { [ServiceContract(Namespace = "http://www.wcftest.com/", SessionMode = SessionMode.Required, CallbackContract = typeof(ITestWcfCallback))] public interface ITestWcf { [OperationContract] void CheckMethod(); [OperationContract] void CheckMethod2(); } public interface ITestWcfCallback { [OperationContract(IsOneWay = true)] void Reply(); } } </pre> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > // WCF 구현 클래스 정의 using System.ServiceModel; namespace WebApplication1 { [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] public class TestWcf : ITestWcfCallback { public void CheckMethod() { } public void CheckMethod2() { } } } </pre> <br /> 마지막으로 test.aspx 웹 페이지를 만들어 WCF 호출을 해봅니다.<br /> <br /> <pre style='margin: 10px 0px 10px 10px; padding: 10px 0px 10px 10px; background-color: #fbedbb; overflow: auto; font-family: Consolas, Verdana;' > using System; using System.ServiceModel; namespace WebApplication1 { public partial class test : System.Web.UI.Page { public class TestCallback : ITestWcfCallback { public void Reply() { } } protected void Page_Load(object sender, EventArgs e) { string hostName = Request.Url.Host.ToLowerInvariant(); int hostPort = Request.Url.Port; TestCallback tcb = new TestCallback(); InstanceContext ctx = new InstanceContext(tcb); // http://localhost:.../WCFs/TestWcf.svc/addrWsDualHttpBinding string wsDualBindingAddress = string.Format("http://{0}:{1}/TestWcf.svc/addrWsDualHttpBinding", hostName, hostPort); WSDualHttpBinding wsDualHttpBinding = new WSDualHttpBinding(); wsDualHttpBinding.Security.Mode = WSDualHttpSecurityMode.None; DuplexChannelFactory<ITestWcf> factory = new DuplexChannelFactory<ITestWcf>(ctx, wsDualHttpBinding, new EndpointAddress(wsDualBindingAddress)); { ITestWcf proxy = factory.CreateChannel(); proxy.CheckMethod(); proxy.CheckMethod2(); IClientChannel comm = proxy as IClientChannel; try { comm.Close(); } catch { comm.Abort(); throw; } finally { try { factory.Close(); } catch { factory.Abort(); } } } } } } </pre> <br /> 이렇게 만든 웹 사이트를 Windows Server 2003 x86 환경과 그 외의 테스트 서버 환경에 각각 배포해 봅니다. (.NET 3.5든, .NET 4.0이든 상관없습니다.)<br /> <br /> 준비가 되었으면 test.aspx 웹 페이지를 방문해서 테스트를 해보면 되는데요. 이상하게도 윈도우 서버 2003 x86에서만 다음과 같이 오류가 발생했습니다.<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state. <br /> Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br /> <br /> Exception Details: System.ServiceModel.CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.<br /> <br /> Source Error: <br /> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. <br /> <br /> Stack Trace: <br /> [CommunicationObjectFaultedException: The communication object, System.ServiceModel.Channels.ServiceChannel, cannot be used for communication because it is in the Faulted state.]<br /> System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +7600991<br /> System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +275<br /> WebApplication1.ITestWcf.CheckMethod2() +0<br /> WebApplication1.test.Page_Load(Object sender, EventArgs e) in d:\...\WebApplication1\test.aspx.cs:37<br /> System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14<br /> System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35<br /> System.Web.UI.Control.OnLoad(EventArgs e) +99<br /> System.Web.UI.Control.LoadRecursive() +50<br /> System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627<br /> --------------------------------------------------------------------------------<br /> Version Information: Microsoft .NET Framework Version:2.0.50727.3643; ASP.NET Version:2.0.50727.3634<br /> </div><br /> <br /> 또는 다음과 같은 오류가 발생하는 경우도 있습니다. (Dual 채널에 대한 callback 인터페이스를 구현하지 않았을 때!)<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> The remote endpoint no longer recognizes this sequence. This is most likely due to an abort on the remote endpoint. The value of wsrm:Identifier is not a known Sequence identifier. The reliable session was faulted. <br /> Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br /> <br /> Exception Details: System.ServiceModel.CommunicationException: The remote endpoint no longer recognizes this sequence. This is most likely due to an abort on the remote endpoint. The value of wsrm:Identifier is not a known Sequence identifier. The reliable session was faulted.<br /> <br /> Source Error: <br /> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. <br /> <br /> Stack Trace: <br /> [CommunicationException: The remote endpoint no longer recognizes this sequence. This is most likely due to an abort on the remote endpoint. The value of wsrm:Identifier is not a known Sequence identifier. The reliable session was faulted.]<br /> System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +221<br /> System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +883<br /> WebApplication1.ITestWcf.CheckMethod2() +0<br /> WebApplication1.test.Page_Load(Object sender, EventArgs e) in d:\...\WebSiteTest\test.aspx.cs:365<br /> System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14<br /> System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +43<br /> System.Web.UI.Control.OnLoad(EventArgs e) +91<br /> System.Web.UI.Control.LoadRecursive() +74<br /> System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2645<br /> --------------------------------------------------------------------------------<br /> Version Information: Microsoft .NET Framework Version:2.0.50727.3643; ASP.NET Version:2.0.50727.3634<br /> </div><br /> <br /> 재미있는 점은, 위의 오류가 초기에 발생하다가 어느 순간부터는 정상적으로 서비스를 한다는 것입니다. 그런데 ^^ 더욱 재미있는 점은 가끔 초기 호출이 많이 몰렸을 때 정상 서비스 상태로 진입하지 못하고 다음과 같은 예외로 넘어가는 경우도 있었는데요.<br /> <br /> <div style='BACKGROUND-COLOR: #ccffcc; padding: 10px 10px 5px 10px; MARGIN: 0px 10px 10px 10px; FONT-FAMILY: Malgun Gothic, Consolas, Verdana; COLOR: #005555'> The request to create a reliable session has been refused by the RM Destination. Server 'http://testsrv:10800/TestWcf.svc/addrWsDualHttpBinding' is too busy to process this request. Try again later. The channel could not be opened. <br /> Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. <br /> <br /> Exception Details: System.ServiceModel.ServerTooBusyException: The request to create a reliable session has been refused by the RM Destination. Server 'http://testsrv:10800/TestWcf.svc/addrWsDualHttpBinding' is too busy to process this request. Try again later. The channel could not be opened.<br /> <br /> Source Error: <br /> An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. <br /> <br /> Stack Trace: <br /> [ServerTooBusyException: The request to create a reliable session has been refused by the RM Destination. Server 'http://testsrv:10800/TestWcf.svc/addrWsDualHttpBinding' is too busy to process this request. Try again later. The channel could not be opened.]<br /> System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +222<br /> System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +883<br /> WebApplication1.ITestWcf.CheckMethod2() +0<br /> WebApplication1.test.Page_Load(Object sender, EventArgs e) in d:\...\WebApplication1\test.aspx.cs:25<br /> System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14<br /> System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +43<br /> System.Web.UI.Control.OnLoad(EventArgs e) +91<br /> System.Web.UI.Control.LoadRecursive() +74<br /> System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +2645<br /> --------------------------------------------------------------------------------<br /> Version Information: Microsoft .NET Framework Version:2.0.50727.3643; ASP.NET Version:2.0.50727.3634 <br /> </div><br /> <br /> 일단 한번 ServerTooBusyException 예외가 발생하면 그 이후로는 iisreset을 하기 전까지 WCF 서비스가 완전히 먹통이 되었습니다.<br /> <br /> 물론, 지금까지 설명한 모든 현상들이 윈도우 서버 2003 x64나 2008 R2 등의 환경에서는 동일한 소스에 동일한 AppPool설정임에도 전혀 발생하지 않았습니다. (그 외 다른 서버는 테스트 하지 않았습니다.) 심지어 같은 2003 서버내에서도 wsDualHttpBinding WCF 서비스를 콘솔 응용 프로그램에서 호스팅하는 경우 정상적으로 동작을 했습니다.<br /> <br /> 게다가, 위의 소스 코드에 보면 CheckMethod, CheckMethod2 2개의 호출을 부르고 있는데요. 매번 오류가 발생하는 곳은 CheckMethod2였는데, 이 메소드를 없애고 CheckMethod 한개만 부르면 이런 오류가 다시 발생하지 않았습니다.<br /> <br /> 정리해 보면, 이번 글의 해결책은 없습니다. 제가 가지고 있는 2003 x86 테스트 서버의 환경적인 문제일 수도 있고... 기타 여러 환경적인 요인을 배제할 수 없으므로 단순히 이런 현상을 겪었음을 설명하는 것입니다. (그래도 왠지 ^^ wsDualHttpBinding WCF 서비스를 해야 한다면 2008 R2에서 하고 싶군요.)<br /> </p><br /> <br /><hr /><span style='color: Maroon'>[이 글에 대해서 여러분들과 의견을 공유하고 싶습니다. 틀리거나 미흡한 부분 또는 의문 사항이 있으시면 언제든 댓글 남겨주십시오.]</span> </div>
첨부파일
스팸 방지용 인증 번호
1331
(왼쪽의 숫자를 입력해야 합니다.)