Microsoft MVP성태의 닷넷 이야기
WCF namedpipe 퍼블리싱 충돌 문제 [링크 복사], [링크+제목 복사],
조회: 13925
글쓴 사람
에메
홈페이지
첨부 파일
(연관된 글이 2개 있습니다.)

안녕하세요, 최근 위 제목과 관련한 문제로 어려움을 겪고 있던 중 혹시 도움을 부탁드릴 수 있을까 해서 글을 남겨 봅니다.

문제를 개략적으로 설명하면 아래와 같습니다.

1. 저희 애플리케이션 (A라고 칭하겠습니다)는 특정한 경우 프로세스 A_proc을 실행시키고 WCF namedpipe를 이용하여 프로세스간 통신을 하고 있습니다.

이 때 namedpipe는

base address : "net.pipe://localhost/servicename/{47280BB5-44EE-49F0-B440-F83878349985}"
identifier : 0~5 (retry 횟수입니다)

로, 완성된 uri는 net.pipe://localhost/servicename/{47280BB5-44EE-49F0-B440-F83878349985}/0 과 같은 형식이 됩니다.

A는 일반 유저 권한으로 실행되고 A_proc을 실행하기 전 WCF host를 생성합니다.
A_proc은 -runas 파라미터로 실행되어 관리자 권한을 획득한 다음 실행됩니다.

보통의 경우 client(A_proc)은 문제없이 채널을 생성하고 A에서 생성된 host에 접속하고 있습니다.

2. 어플리케이션이 릴리즈된 이후 #1의 커넥션이 생성되지 않는 경우를 발견하게 되었는데, 타사의 어플리케이션 B가 다음과 같이 행동할 경우 문제가 발생함을 확인할 수 있었습니다.

- B는 일반 어플리케이션이 아닌 Windows Service로 작동
- Windows Service내에서 B는 namedpipebinding을 이용한 WCF Host생성
- namedpipe는
base address : "net.pipe://localhost"
identifer : any identifier

로, 완성된 uri는 "net.pipe://localhost/identifier"이지만 base address가 net.pipe://localhost로 최상위 endpoint address인 상태입니다.



이 때 B의 Service가 사용자의 시스템에서 실행중일 경우, A_proc의 클라이언트는 A의 Host에 접속하는 대신 B로 접속을 시도하고, service contract가 맞지 않기 때문에 preamble handshake에 실패하고 아래와 같은 exception stacktrace를 남기고 있습니다.

Unhandled Exception: System.ServiceModel.EndpointNotFoundException: There was no
 endpoint listening at net.pipe://localhost/anothersevice/{47280BB5-44EE-49F0-B4
40-F83878349985}/identifier that could accept the message. This is often caused
by an incorrect address or SOAP action. See InnerException, if present, for more
 details.

Server stack trace:
   at System.ServiceModel.Channels.ConnectionUpgradeHelper.DecodeFramingFault(Cl
ientFramingDecoder decoder, IConnection connection, Uri via, String contentType,
 TimeoutHelper& timeoutHelper)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.SendPreambl
e(IConnection connection, ArraySegment`1 preamble, TimeoutHelper& timeoutHelper)

   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.DuplexConne
ctionPoolHelper.AcceptPooledConnection(IConnection connection, TimeoutHelper& ti
meoutHelper)
   at System.ServiceModel.Channels.ConnectionPoolHelper.EstablishConnection(Time
Span timeout)
   at System.ServiceModel.Channels.ClientFramingDuplexSessionChannel.OnOpen(Time
Span 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)
   at System.ServiceModel.Channels.ServiceChannel.CallOnceManager.CallOnce(TimeS
pan timeout, CallOnceManager cascade)
   at System.ServiceModel.Channels.ServiceChannel.EnsureOpened(TimeSpan timeout)

   at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean on
eway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan tim
eout)
   at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCall
Message methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)


유사한 문제가 있는지 찾아본 결과 http://stackoverflow.com/questions/15981392/3rd-party-app-breaks-our-wcf-application/15987095#15987095 이런 질문을 찾을 수 있었는데, 현재 겪고 있는 문제와 같은 문제로 보여지지만 해결책은 찾을 수가 없었습니다.

일반 소비자용으로 배포되는 어플리케이션이라 B가 어떤 어플리케이션인지 특정할 수 없고, 사용자에게 직접 연락해서 사용자의 시스템 상태를 확인하기도 어려운 상황입니다만, 이런 상황에서

1. namedpipe 충돌을 피할 수 있는 방법이 있을까요?
2. 접속하는 클라이언트 (A_proc) 쪽에서 위와 같이 실패했을 때, 접속을 시도한 host가 어떤 쪽인지 파악할 수 있는 방법이 있을까요?

감사합니다.

p.s : 재현을 위해 간단하게 구현한 프로젝트를 첨부하였습니다. 총 3개의 프로젝트이며, 2개의 sln입니다.
1. localhost : Service B를 흉내낸 서비스 구현입니다. %systemroot%\microsoft.net\framework\v4.0xxxx\installutil 을 이용하여 서비스로 설치한 후 서비스를 구동하였습니다.
2. wcf test : A를 흉내낸 host 어플리케이션입니다. 일반 유저 권한으로 실행하여 host를 생성하였습니다.
3. wcf client test : A_proc을 흉내낸 클라이언트입니다. admin 권한으로 실행하여 host에 접속을 시도합니다.



[연관 글]






[최초 등록일: ]
[최종 수정일: 11/7/2014]


비밀번호

댓글 작성자
 



2014-11-07 06시35분
[에메] 혹시나 해서 덧붙이면 #1의 base address "net.pipe://localhost/servicename/{47280BB5-44EE-49F0-B440-F83878349985}" 에서 service name과 GUID는 실제로 사용하고 있는 것은 아니고, scheme을 설명하기 위해 임의로 기입하였습니다.
[guest]
2014-11-10 12시41분
답변이 많이 늦었습니다. 아래의 글로 정리해 두었으니 참고해 주세요. ^^

SeCreateGlobalPrivilege 특권과 WCF NamedPipe
; http://www.sysnet.pe.kr/2/0/1806
정성태
2014-11-13 09시37분
[에메] 감사합니다! 어떻게 해결할지는 아직 고민중이긴 하지만, 덕분에 문제를 정리할 수 있었습니다.
[guest]

... [91]  92  93  94  95  96 
NoWriterDateCnt.TitleFile(s)
155최성우4/18/20058054[질문(--),(__)]BHO로 자동 로그인 기능 구현.. 패스워드를 읽어오지를 못합니다.
156정성태4/19/20056993    답변글 [답변]: [질문(--),(__)]BHO로 자동 로그인 기능 구현.. 패스워드를 읽어오지를 못합니다.
161최성우4/21/20057837        답변글 [답변]: [답변]: [질문(--),(__)]BHO로 자동 로그인 기능 구현.. 패스워드를 읽어오지를 못합니다.
164정성태4/22/20056776            답변글 [답변]: [답변]: [답변]: [질문(--),(__)]BHO로 자동 로그인 기능 구현.. 패스워드를 읽어오지를 못합니다.
176최성우5/3/20057183                답변글 [답변]: [답변]: [답변]: [답변]: [질문(--),(__)]BHO로 자동 로그인 기능 구현.. 패스워드를 읽어오지를 못합니다.
146안연준4/14/20057959컴포넌트 안에 컴포넌트 삽입? 헐 ! -_-;;
147정성태4/14/20056827    답변글 [답변]: 컴포넌트 안에 컴포넌트 삽입? 헐 ! -_-;;
148안연준4/15/20057135        답변글 [답변]: [답변]: 컴포넌트 안에 컴포넌트 삽입? 헐 ! -_-;; [2]
142김용국4/13/20057022SmartClient 방식에서 이미지(바이너리)파일을 DataBased에 저장하기위한 방안에 대한 문의
143정성태4/14/20056626    답변글 [답변]: SmartClient 방식에서 이미지(바이너리)파일을 DataBased에 저장하기위한 방안에 대한 문의
141김종욱4/12/20057002웹하드 시스템을 ACTIVEX 로 짜고 있습니다
144정성태4/14/20056783    답변글 [답변]: 웹하드 시스템을 ACTIVEX 로 짜고 있습니다
149김종욱4/15/20056472        답변글 [답변]: [답변]: 웹하드 시스템을 ACTIVEX 로 짜고 있습니다 [1]
150정성태4/15/20056804            답변글 [답변]: [답변]: [답변]: 웹하드 시스템을 ACTIVEX 로 짜고 있습니다 [1]
151김종욱4/16/20056959                답변글 [답변]: [답변]: [답변]: [답변]: 웹하드 시스템을 ACTIVEX 로 짜고 있습니다
152정성태4/16/20056847                    답변글 [답변]: [답변]: [답변]: [답변]: [답변]: 웹하드 시스템을 ACTIVEX 로 짜고 있습니다
153김종욱4/18/20058524                        답변글 [답변]: [답변]: [답변]: [답변]: [답변]: [답변]: 웹하드 시스템을 ACTIVEX 로 짜고 있습니다
154정성태4/18/20057881                            답변글 [답변]: [답변]: [답변]: [답변]: [답변]: [답변]: [답변]: 웹하드 시스템을 ACTIVEX 로 짜고 있습니다 [3]
140안연준4/11/20056709Smart Client 에서 오프라인 글 중...의문점
145정성태4/14/20056479    답변글 [답변]: Smart Client 에서 오프라인 글 중...의문점 [1]
134김용국4/6/200511012c# .Net 에 대한 문의좀 ^^ [WinForm 에서 UserControl로 작성된 폼을 호출하려는데....]
135정성태4/6/20059113    답변글 [답변]: c# .Net 에 대한 문의좀 ^^ [WinForm 에서 UserControl로 작성된 폼을 호출하려는데....]
136김용국4/6/20057737        답변글 [답변]: [답변]: c# .Net 에 대한 문의좀 ^^ [WinForm 에서 UserControl로 작성된 폼을 호출하려는데....]
137정성태4/7/20056986            답변글 [답변]: [답변]: [답변]: c# .Net 에 대한 문의좀 ^^ [WinForm 에서 UserControl로 작성된 폼을 호출하려는데....]
138김용국4/7/20056005                답변글 [답변]: [답변]: [답변]: [답변]: c# .Net 에 대한 문의좀 ^^ [WinForm 에서 UserControl로 작성된 폼을 호출하려는데....]
139김용국4/11/20056416                    답변글 잘 해결 되었습니다... 감사합니다 [한줄답변]
... [91]  92  93  94  95  96