IIS에서 WCF 서비스를 실행하고 있습니다. 클라이언트는 net.tcp를 통해 연결합니다. 하나의 실제 머신이 클라이언트 어플리케이션의 두 인스턴스를 열 때까지 모든 것이 잘 작동합니다. 그런 다음 두 번째 애플리케이션 만 서비스에서 제공됩니다.하나의 실제 컴퓨터에서 다른 WCF 서비스에 대한 여러 인스턴스
하나의 컴퓨터가 srvAddress : port/service.svc에 대한 연결을 여는 포트 문제이며 서버가 응답해야하는 클라이언트 인스턴스를 알지 못한다고 가정합니다.
첫 번째 질문 : client1 (pc1)에서 ip : port/service.svc를 열면 WCF가 응답에 사용할 로컬 클라이언트 포트는 무엇입니까? 그런 다음 client2 (아직 pc1)에서 ip : port/service.svc를 열면 WCF가 제대로 처리하지 못하는 이유는 무엇입니까?
서버 :
[ServiceBehavior(ConcurrencyMode = ConcurrencyMode.Reentrant, InstanceContextMode = InstanceContextMode.PerSession)]
public class WCFService : IWCFService
{
public State OpenSession(string clientKey)
{
Callback = OperationContext.Current.GetCallbackChannel<IWCFServiceCallback>();
}
}
클라이언트 :
var callback = new WCFServiceCallback();
var instanceContext = new InstanceContext(callback);
Server = new WCFServiceClient(instanceContext);
Server.OpenSession("secret");
WCF 구성 서버
<?xml version="1.0"?>
<configuration>
<system.web>
<customErrors mode="Off"/>
<compilation/>
</system.web>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<!-- Add the following element to your service behavior configuration. -->
<serviceMetadata httpGetEnabled="true"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<!--Hosting in a IIS: -->
<service name="WCFServiceLibrary.Service.WCFService">
<endpoint address="net.tcp://myservice.com:808/Service.svc" binding="netTcpBinding" bindingConfiguration="InsecureTcp" contract="WCFServiceLibrary.Contract.IWCFService" />
<host>
<baseAddresses>
<add baseAddress="http://myservice.com/Service/"/>
</baseAddresses>
</host>
<endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex"/>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="InsecureTcp" maxBufferPoolSize="2147483647" maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
<security mode="None" />
<readerQuotas maxDepth="2000000" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
</binding>
</netTcpBinding>
</bindings>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true"/>
</system.serviceModel>
</configuration>
WCF 구성 클라이언트
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<section name="Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false"/>
</sectionGroup>
</configSections>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="NetTcpBinding_IWCFService">
<security mode="None"/>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://myservice.com/Service.svc" binding="netTcpBinding" bindingConfiguration="NetTcpBinding_IWCFService" contract="ServiceReference.IWCFService" name="NetTcpBinding_IWCFService"/>
</client>
</system.serviceModel>
<userSettings />
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>
WCF 클라이언트 구성에 이상하게 보입니다. 그것은 단지 하나의 서비스 만 제공한다는 것이 놀랍지는 않습니다. 전체 구성 파일을 볼 수 있습니까? – Aelphaeis
안녕하세요 @Aelphaeis 요청하신대로 구성을 업데이트했습니다 :-) – libjup