Azure service fabric 客户端正在尝试连接到服务结构ServiceProxy上的无效地址

Azure service fabric 客户端正在尝试连接到服务结构ServiceProxy上的无效地址,azure-service-fabric,service-fabric-stateful,Azure Service Fabric,Service Fabric Stateful,我在服务结构6上有一个Asp.net Core 2.0无状态服务和一个Asp.net Core 2.0有状态服务,分区数为10 我遵循了这个教程 我遵循了所有步骤,除了在VisualStudio中使用模板 CreateServiceReplicaListeners正在使用KestreCommunicationListener protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaLis

我在服务结构6上有一个Asp.net Core 2.0无状态服务和一个Asp.net Core 2.0有状态服务,分区数为10

我遵循了这个教程

我遵循了所有步骤,除了在VisualStudio中使用模板 CreateServiceReplicaListeners正在使用KestreCommunicationListener

 protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
    {
        return new ServiceReplicaListener[]
        {
            new ServiceReplicaListener(serviceContext =>
                new KestrelCommunicationListener(serviceContext, (url, listener) =>
                {
                    return new WebHostBuilder()
                                .UseKestrel()
                                .ConfigureServices(
                                    services => services
                                        .AddSingleton<StatefulServiceContext>(serviceContext)
                                         .AddSingleton<IReliableStateManager>(this.StateManager))
                                .UseContentRoot(Directory.GetCurrentDirectory())
                                .UseStartup<Startup>()
                                .UseServiceFabricIntegration(listener, ServiceFabricIntegrationOptions.UseUniqueServiceUrl)
                                .UseUrls(url)
                                .Build();
                }))
        };
    }
protectedoverride IEnumerable CreateServiceReplicaListeners()
{
返回新的ServiceReplicaListener[]
{
新建ServiceReplicaListener(serviceContext=>
新KestreCommunicationListener(serviceContext,(url,listener)=>
{
返回新的WebHostBuilder()
.UseKestrel()
.配置服务(
服务=>服务
.AddSingleton(serviceContext)
.AddSingleton(此.StateManager))
.UseContentRoot(目录.GetCurrentDirectory())
.UseStartup()
.UseServiceFabricIntegration(侦听器,ServiceFabricIntegrationOptions.UseUniqueServiceUrl)
.useURL(url)
.Build();
}))
};
}
使用以下代码调用Asp.net Core 2.0无状态服务中的服务时:

var service = ServiceProxy.Create<IStorageService>(new Uri("fabric:/MyCluster/Storage"), new ServicePartitionKey(Fnv1aHashCode.Get64bitHashCode(User.Id)));
await service.MyMethod();
var service=ServiceProxy.Create(新Uri(“结构:/MyCluster/Storage”)、新ServicePartitionKey(Fnv1aHashCode.Get64bitHashCode(User.Id));
wait service.MyMethod();
调用“MyMethod”时引发异常

客户端试图连接到无效地址。

异常中存在的url存在于服务结构资源管理器中,并且端口和分区键正确。 ServiceManifest中没有设置端点,因为有状态服务基本上只是模板,添加了IService接口和MyMethod方法,如上面的教程所示

我错过了什么? Asp.net Core 2.0的文档不是最新的

我试图不使用分区,设置了
ServicePartitionKey(0)
,但结果相同


我不知道如何继续。

您混合了两个完全不同的通信堆栈:

  • 在您的服务中,您使用的是公开HTTP端点的KestreCommunicationListener
  • 在您的客户机中,您使用的是ServiceProxy,它使用的是完全不同的
你不能把两者混为一谈。您需要使用HTTP客户端与服务的HTTP端点进行通信。在服务结构中有一个HTTP,它将为您执行服务发现和请求转发,使之更容易。还有一个允许您使用简单DNS名称寻址其他服务的

在您参考的教程中,后端服务使用服务远程处理侦听器,该侦听器公开ServiceProxy要连接到的RPC端点:

protected override IEnumerable<ServiceReplicaListener> CreateServiceReplicaListeners()
{
    return new List<ServiceReplicaListener>()
    {
        new ServiceReplicaListener(
            (context) =>
                this.CreateServiceRemotingListener(context))
    };
}
protectedoverride IEnumerable CreateServiceReplicaListeners()
{
返回新列表()
{
新ServiceReplicaListener(
(上下文)=>
this.CreateServiceRemotingListener(上下文))
};
}

谢谢,我混淆了这两个堆栈。您是否可以共享关于如何使用KestrelCommunicationListener公开的HTTP端点调用公开的端点的代码或文档?