私はそれが次のコードでの作業を取得するために管理してきました:
public class CustomHandler : DelegatingHandler
{
private static readonly FabricClient FabricClient = new FabricClient();
private static readonly HttpCommunicationClientFactory CommunicationFactory = new HttpCommunicationClientFactory(new ServicePartitionResolver(() => FabricClient));
public CustomHandler() : base(new HttpClientHandler()) {}
protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
var partitionClient = new ServicePartitionClient<HttpCommunicationClient>(CommunicationFactory, new Uri("fabric:/IdentityService/AuthApi"));
return await partitionClient.InvokeWithRetryAsync(
async (client) =>
{
//replace base address with resolved url of internal endpoint
request.RequestUri = new Uri(client.Url, request.RequestUri.PathAndQuery);
return await base.SendAsync(request, cancellationToken);
}, cancellationToken);
}
}
注HttpCommunicationClientFactory、HttpCommunicationClientはhere定義されたパターンに従うこと。
IdSrvもPublicOriginで構成する必要がありました。そうしないと、JWTオーディエンス値は、サービスがどのノードにあるかによって異なる可能性があります。
ありがとう、HttpMessageHandlerで可能だったのかどうか疑問に思っていましたが、わかりませんでした(私に!)。私はそのアプローチをもう一度見て、あなたに戻ってきます – isaacmcn
この例に感謝し、このアプローチを指摘してください!私はそれを次のコードで動作させることができました: – isaacmcn
私はそれをあなたの例と[service fabric docs](https://azure.microsoft.com/en-us/documentation)に基づいたコードを使って動作させることができました/ articles/service-fabric-reliable-services-communication /)。私はコードサンプルを投稿することができますが、それはコメントのためには長すぎます、ここのエチケットは何ですか? :-) – isaacmcn