【问题标题】:Communicating with containerized WCF service in Service fabric与 Service Fabric 中的容器化 WCF 服务通信
【发布时间】:2018-12-13 16:34:48
【问题描述】:

我有一个在 SF 中运行的容器。 WCF 服务在容器内的 7777 端口上运行,并绑定到同一端口上的主机。

我编写了第二个 SF 服务并将其部署在集群上。 我已经使用 WCFComuunicationClientFactory 与容器内运行的 WCF 服务通信。

但是,我在 uri 上遇到类型异常:EndPointNotFoundException: net.tcp://MyPc.XXX.com:7777/。 这是有道理的,因为合约是以这种方式公开的:net.tcp://MyPc.XXX.com:7777/ContractType。

我怎样才能让它工作? 我附上了试图联系容器的服务代码:

 var wcfClientFactory = new WcfCommunicationClientFactory<MyContractService>(
         clientBinding: binding, 
         servicePartitionResolver: partitionResolver
     );

 var newClient = wcfClientFactory.GetClientAsync(
         new Uri("fabric:/MyContainerService"), 
         ServicePartitionKey.Singleton,
         TargetReplicaSelector.Default, 
         null, 
         new OperationRetrySettings(), 
         CancellationToken.None
     ).Result;

 var x = newClient.Channel.GetX();

当访问“Ge​​tX”时,我得到了端点异常。

【问题讨论】:

    标签: c# wcf docker azure-service-fabric


    【解决方案1】:

    解决方案位于服务结构 serviceManifest.xml 文件中的容器端点定义内。

    可以添加一个pathSuffix,像这样:

    <Endpoint Name="MyEndPoint" UriScheme="net.tcp" Port="3000" Protocol="tcp" PathSuffix="YourService" />
    

    这将导致以下终点:

    net.tcp://<host>:3000/YourService
    

    请注意,您可以拥有任意数量的端点,并且为了从与容器内的服务联系的客户端中选择一个,您应该在创建代表您的端点的“ServicePartitionClient”时指定参数:“listenerName”名字。

    【讨论】:

      猜你喜欢
      • 2020-10-24
      • 2018-03-13
      • 2016-08-30
      • 2017-06-09
      • 2017-10-30
      • 2021-03-01
      • 2016-01-19
      • 1970-01-01
      • 2019-06-21
      相关资源
      最近更新 更多