0

I am using following code to make an http call to external service provider lokalise.

        var client = new HttpClient();
        client.DefaultRequestHeaders.Add("x-api-token", _config.GetSection("Localize:ApiToken").Value);
        var response = await client.GetAsync(_config.GetSection("Localize:ApiUrl").Value);
        var localizeResponse = JsonConvert.DeserializeObject<LocalizeResponse>(await response.Content.ReadAsStringAsync());

but I am getting following exception

System.Net.Http.HttpRequestException: Name or service not known\n ---> System.Net.Sockets.SocketException (0xFFFDFFFF): Name or service not known\n   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)\n   --- End of inner exception stack trace ---\n   at System.Net.Http.ConnectHelper.ConnectAsync(String host, Int32 port, CancellationToken cancellationToken)\n   at System.Net.Http.HttpConnectionPool.ConnectAsync(HttpRequestMessage request, Boolean allowHttp2, CancellationToken cancellationToken)\n   at System.Net.Http.HttpConnectionPool.CreateHttp11ConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\n   at System.Net.Http.HttpConnectionPool.GetHttpConnectionAsync(HttpRequestMessage request, CancellationToken cancellationToken)\n   at System.Net.Http.HttpConnectionPool.SendWithRetryAsync(HttpRequestMessage request, Boolean doRequestAuth, CancellationToken cancellationToken)\n   at System.Net.Http.RedirectHandler.SendAsync(H...

Any suggestion what could be the issue, Do I need some kind of proxyfier to make an http call from OCP hosted container? If so then how? any other suggestions?

1 Answers1

0

In general there should not be any limitations from OpenShift side to issue HTTP calls to external services / API by default. If you are a user of an OpenShift service then the following things could be a blocker:

  • In OpenShift you can configure so-called "Egress Firewall" objects which can block access to external hostnames and IPs.
  • If OpenShift is not blocking the traffic then maybe an external firewall in your company could block the traffic targeting the internet.

Also on your own OpenShift server the following problems can cause connection issues:

  • Maybe the DNS Server on your underlying OCP hosts is not configured properly so this also needs to be verified. Does the traffic work for other namespaces?
  • I have also seen in the past that OpenShift nodes can have connection issues when the node in general has a problem so I would recommend trying to start your pod on a different node to verify if the node has a problem

I hope this helps you. Let me know if I can help further.

  • So the problem was, we were trying to access the external sevice without a proxy server. After introducing the proxy server, connection is working now. – Saqib Shehzad Apr 11 '22 at 09:51