admin管理员组

文章数量:1129449

I have a pariticalur use case while using a stateless service where I need to hit an APS.NET endpoint of all the other instance from one given instance of my service in Service Fabric. I did attempted this via geting node.IpAddressOrFQDN of all nodes and making an HTTP call either directly to the port on which service is hosted or calling DNS but HTTP call is failing. Any idea about how achieve this use case ?

Calling exact port and enpoint

                FabricClient fabricClient = new FabricClient();
                NodeList nodes = await fabricClient.QueryManager.GetNodeListAsync();
                foreach (Node node in nodes) 
                { 
                    var nodeIpAddr = node.IpAddressOrFQDN;
                    string httpAddress = $"http://{nodeIpAddr}:<port>/api/endpoint";
                    string httpsAddress = $"https://{nodeIpAddr}:<port>/api/endpoint";
                    HttpClient client = new HttpClient();
                    var responseA = await client.GetAsync(httpsAddress);
                    var responseB = await client.GetAsync(httpAddress);
                }
                return Ok();

Calling DNS

                FabricClient fabricClient = new FabricClient();
                NodeList nodes = await fabricClient.QueryManager.GetNodeListAsync();
                foreach (Node node in nodes) 
                { 
                    var nodeIpAddr = node.IpAddressOrFQDN;
                    string httpAddress = $"http://{nodeIpAddr}:19081/Service/Application/api/endpoint";
                    string httpsAddress = $"https://{nodeIpAddr}:19081/Service/Application/api/endpoint";
                    HttpClient client = new HttpClient();
                    var responseA = await client.GetAsync(httpsAddress);
                    var responseB = await client.GetAsync(httpAddress);
                }
                return Ok();

Exception in HTTPS call

Error: The SSL connection could not be established, see inner exception. The SSL connection could not be established, see inner exception.    at System.Net.Http.ConnectHelper.EstablishSslConnectionAsync(SslClientAuthenticationOptions sslOptions, HttpRequestMessage request, Boolean async, Stream stream, CancellationToken cancellationToken)

HTTP Call response

StatusCode: 404, ReasonPhrase: 'FABRIC_E_ENDPOINT_NOT_FOUND', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
{
  Server: Microsoft-HTTPAPI/2.0
  Date: Wed, 08 Jan 2025 13:45:29 GMT
  Content-Length: 0
}

本文标签: aspnet web apiHow to call endpoints from one node in Service Fabric to all the other nodesStack Overflow