简体   繁体   中英

Communicating with containerized WCF service in Service fabric

I have a container running in SF. A WCF service is running inside the container on port 7777 and is bind to the host on the same port.

I have written a second SF service and deployed it on the cluster. I have used the WCFComuunicationClientFactory to talk to the WCF service running inside the container.

However, I am getting an exception of type: EndPointNotFoundException on uri: net.tcp://MyPc.XXX.com:7777/. This makes sense since the contracts are exposed this way: net.tcp://MyPc.XXX.com:7777/ContractType.

How can I make it work? I am attaching the code of the service trying to contact the container:

 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();

when Accessing 'GetX' I get the endpoint exception.

The solution is inside the container endpoint definition in the service fabric serviceManifest.xml file.

It is possible to add a pathSuffix, like this:

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

This will result in the following end point:

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

Notice you can have as many as endpoints as you like, and in order to choose one from the client contacting the service inside the container, you should specify the parameter: 'listenerName' when creating 'ServicePartitionClient', which represents your EndPoint name.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM