I have 2 .net core 2.2 applications running in Kubernetes cluster. The services use HttpClient.SendAsync
to communicate with one another through Kubernetes services. The applications work well on bare-metals. However, the communication with HttpClient
throws No such device or address exception
. Here is one of the URLs used: http://svc-biz4xbackend:5002/api/v1/Identity/SessionValidate
. I kubectl exec
into the pod and curl
the url and it works fine. Does this indicate that this could be a bug with .Net Core framework? Where should I start to debug?
private async Task<HttpResponseMessage> Send(HttpMethod method, string url, HttpContent content, CancellationToken cancel, TimeSpan timeout = default)
{
try {
var client = _client;
if (timeout != default)
client.Timeout = timeout;
Uri uri = new Uri($"{client.BaseAddress}{url}", UriKind.Absolute);
using (var httpRequestMessage = new HttpRequestMessage(method, uri))
{
if ((method == HttpMethod.Post || method == HttpMethod.Put) && content != null)
httpRequestMessage.Content = content;//new StringContent(JsonConvert.SerializeObject(postData), _encoding, "application/json");
httpRequestMessage.Headers.Add("X-User-Id", new List<string>() {_authzContext.UserId});
httpRequestMessage.Headers.Add("X-Session-Id", new List<string>() {_authzContext.SessionId});
return await client.SendAsync(httpRequestMessage, cancel);
}
} catch (Exception e) {
_logger.LogCritical($"Client.{nameof(Send)} url: {_client.BaseAddress}{url} Exception! {e.Message} {e.GetInnerMessage()} {e.StackTrace}");
return null;
}
}