2012-11-19 5 views
3

IIS가없는 서버에서 호스트되며 인증없이 일반인이 액세스 할 수있는 tcp wcf 서비스를 만들려고합니다.공용 WCF 서비스를 호스팅하는 방법은 무엇입니까?

ServiceHost svh = new ServiceHost(typeof(MyService)); 

var tcpbinding = new NetTcpBinding(SecurityMode.None); 

var location = "net.tcp://localhost:11111"; 
svh.AddServiceEndpoint(typeof(IMyService), tcpbinding, location); 

svh.Open(); 
.... 

서비스는 locashost에 잘 작동하지만 내가 (방화벽 예외 추가) 서버를 설정할 때, 클라이언트는 메시지와 함께 충돌 :

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.7344663'. 
여기

내가 할 것입니다

나는이에 대한 변경해야합니까
<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <startup> 
     <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> 
    </startup> 
    <system.serviceModel> 
     <bindings> 
      <netTcpBinding> 
       <binding name="NetTcpBinding_IMyService"> 
        <security mode="None" /> 
       </binding> 
      </netTcpBinding> 
     </bindings> 
     <client> 
      <endpoint address="net.tcp://myserver:11111/" 
       binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IMyService" 
       contract="MyServer.IMyService" name="NetTcpBinding_IMyService" /> 
     </client> 
    </system.serviceModel> 
</configuration> 

작동하려면 :

다음은 클라이언트 구성 파일입니까?

+0

당신은 http://msdn.microsoft.com/en-us/library/bb332338.aspx을 읽어나요? –

답변

1

이전에도 비슷한 문제가 있었지만 실제 주소를 사용하여 끝점 주소 (ServiceHost .ctor)에 localhost을 사용하지 않고 해결했습니다. 또한 아래와 같이 서비스 호스트 자체에서 주소를 정의 할 수 있습니다.

ServiceHost svh = new ServiceHost(typeof(MyService), new Uri("net.tcp://myserver:11111")); 
var tcpbinding = new NetTcpBinding(SecurityMode.None); 
svh.AddServiceEndpoint(typeof(IMyService), tcpbinding, ""); 
svh.Open(); 
+0

예,이 기능이 작동했습니다. 감사 –

관련 문제