Hi,
I just encountered a weird issue when running my aspnet core web services in an Azure Kubernetes, environment.
I repeatedly received a "SocketException: Connection reset by peer" error when one web service calls another using PostAsJsonAsync(...). This issues did not occur when running the services outside K8S/Azure.
By inspecting the code of PostAsJsonAsync, I figured out that it eventually makes the following call to PostAsync:
Hi, I just encountered a weird issue when running my aspnet core web services in an Azure Kubernetes, environment.
I repeatedly received a "SocketException: Connection reset by peer" error when one web service calls another using PostAsJsonAsync(...). This issues did not occur when running the services outside K8S/Azure.
By inspecting the code of PostAsJsonAsync, I figured out that it eventually makes the following call to PostAsync:
client.PostAsync(requestUri, content, cancellationToken);
This call fails with the socket exception message.
It turned out that
content
did not have aContent-Length
header. If I add this header tocontent
and then make the call, everything works as expected.This raises two questions:
Any help to resolve this is greatly appreciated.