I am facing an intermittent issue where it throws below exception.
There was no endpoint listening at http://myserver.com/something that could accept the message. System.Net.WebException: The remote name could not be resolved
After much examination came to know that DNS Server configured in the client had correct ipv6 address but wrong ipv4 address. when ipv4 address is changed to correct ipv4 address the issue got solved.
My Question is what can be the reason for the intermittent failure. Why did it not fail always or if it used correct ipv6 address why did it not pass always?
A well behaved client would try each individual DNS recursor before it gives up and give you the The remote name could not be resolved
error.
So in the scenario where you have configured the client with an incorrect IPv4 address and a correct IPv6 address for the recursor, it would never get a reply over IPv4, but as long as it does get a reply over IPv6 it should not give you that error.
However if the IPv6 connection between the client and the recursor is flaky, it can result in intermittent failures.
Once you corrected the IPv4 address for the recursor, you would only get the error message in case neither works. That means the error has become less likely to occur (and possibly even less likely than it would have been with only the IPv4 address).
Thus it is likely that even if the IPv6 connection is indeed still flaky, you might not have noticed because the client did get a response over IPv4 in those cases, where IPv6 didn't work.