Search code examples
azure-service-fabric

The primary or stateless instance for the partition has invalid address


I created a stateful service with the out-of-the-box partitioning:

<StatefulService ServiceTypeName="ExamplesServiceType" TargetReplicaSetSize="[ExamplesService_TargetReplicaSetSize]" MinReplicaSetSize="[ExamplesService_MinReplicaSetSize]">
            <UniformInt64Partition PartitionCount="[ExamplesService_PartitionCount]" LowKey="-9223372036854775808" HighKey="9223372036854775807" />
         </StatefulService>

The service manifest sets the params to (out-of-the-box as well):

 <Parameter Name="ExampleService_PartitionCount" Value="1" />
 <Parameter Name="ExampleService_MinReplicaSetSize" Value="2" />
 <Parameter Name="ExampleService_TargetReplicaSetSize" Value="3" />
 <Parameter Name="WebService_InstanceCount" Value="1" />

Now I want to call to to my stateful service from my stateless service in the same cluster:

 ServiceUriBuilder builder = new ServiceUriBuilder(ExampleServiceName);
 var service = ServiceProxy.Create<IExampleService>(builder.ToUri(),new ServicePartitionKey(1));

 return service.MyCallAsync(id);

I'm getting the following error:

The primary or stateless instance for the partition 'a67f7afa-3370-4e6f-ae7c-15188004bfa1' has invalid address, this means that right address from the replica/instance is not registered in the system

The stateful service I'm trying to reach logs to the event logs and the logs carry "partitionId": "a67f7afa-3370-4e6f-ae7c-15188004bfa1".

What am I missing?


Solution

  • I wasn't registering a remote as explained at http://vunvulearadu.blogspot.com/2016/04/azure-service-fabric-primary-or.html

            protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
        {
            return new[] { new ServiceReplicaListener(context => this.CreateServiceRemotingListener(context)) };
        }