Can I call a stateless service with RPC from outside of a cluster but in the same local network?

1

On my local machine in Visual Studio 2017, I created solution based on the .NET Core Stateless Service template, and added Microsoft.ServiceFabric.Services.Remoting.Runtime package to accept remote calls through RPC.

protected override IEnumerable<ServiceInstanceListener> CreateServiceInstanceListeners()
{
    return this.CreateServiceRemotingInstanceListeners();
}

Then I added interface ITestAccUp in a separate project:

public interface ITestAccUp : IService
{
    Task NotifyAsync();
}

I added implementation of the interface to the stateless service, and created one more project, a .NET Core console client to run the service. The console is going to be run outside a cluster.

static void Main(string[] args)
{
    ITestAccUp testAccUpClient = ServiceProxy.Create<ITestAccUp>(new Uri("fabric:/SFAccountUpTest/Stateless1"));

    testAccUpClient.NotifyAsync().Wait();
}

However, when I run it I got the error "InvalidCastException: Unable to cast COM object of type 'System.__ComObject' to interface type 'IFabricTestManagementClient4'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{B96AA7D4-ACC0-4814-89DC-561B0CBB6028}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).", though Named Application fabric:/SFAccountUpTest/Stateless1 seems to be up and running.

I guess the problem is RPC calls are just made for calling services inside SF clusters, not outside. Is it possible to make an RPC call outside a cluster, or is it necessary to build some sort of web API to make a service call?

solution structure

azure-service-fabric
azure-cloud-services
asked on Stack Overflow Sep 7, 2018 by YMC • edited Mar 10, 2019 by Super Jade

1 Answer

2

As long as you're on the same network, you can call Services and Actors by using SF Remoting from other applications. For example, see this demo project which does so for testing purposes.

Make sure you use the same DLL that holds the interface definition from both the client and the service project. (It works different from WCF, where a proxy could be generated independently from the service, by using wsdl.)

Maybe you're running into an issue, like this one, or this one.

answered on Stack Overflow Sep 8, 2018 by LoekD

User contributions licensed under CC BY-SA 3.0