Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception thrown by SocketsHttpHandler has changed #42554

Closed
mconnew opened this issue Sep 21, 2020 · 5 comments
Closed

Exception thrown by SocketsHttpHandler has changed #42554

mconnew opened this issue Sep 21, 2020 · 5 comments

Comments

@mconnew
Copy link
Member

mconnew commented Sep 21, 2020

Description

When a hostname can't be found, WCF throws System.ServiceModel.EndpointNotFoundException when HttpClient.SendAsync throws a specific exception. The details of the exception have now changed. Previously the exception thrown was System.Net.Http.HttpRequestException with an inner exception of type System.Net.Sockets.SocketException. If the value of SocketException.SocketErrorCode is one of SocketError.TryAgain, SocketError.NoRecovery, SocketError.NoData, or SocketError.HostNotFound, we will throw System.ServiceModel.EndpointNotFoundException.

On a recent test run, there's a new exception class between HttpRequestException and SocketException. The exception now looks like this:

-------- System.Net.Http.HttpRequestException : No such host is known. (nonexisthost:80)
------------ System.Net.NetworkException : No such host is known.
---------------- System.Net.Sockets.SocketException : nodename nor servname provided, or not known

There is now an additional NetworkException in the exception hierarchy.

Configuration

.NET Version: .NET 5.0.100-rc.1.20452.10
OS Version: So far I have seen this on OSX and on Windows 10 so this isn't OS specific

Regression?

This is new different behavior in .NET 5 so it is a regression.

@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added area-System.Net.Http untriaged New issue has not been triaged by the area owner labels Sep 21, 2020
@ghost
Copy link

ghost commented Sep 21, 2020

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@geoffkizer
Copy link
Contributor

This change got reverted. You should see the old exception behavior here in recent RC2 builds.

That said, it would be much better if you didn't have to rely on inner exceptions here. We've talked about having something like HttpRequestErrorCode on HttpRequestMessage; if we had that, presumably there would be a code like HostNotFound and you could check for that. Not sure if we have an issue on this currently...

@mconnew
Copy link
Member Author

mconnew commented Sep 21, 2020

You mean like I requested in #15567 5 years ago before, 8 months before .NET Core 1.0 was released? The problem I now have is WCF is still only targeting netstandard2.0. This is because our package is still supported on .NET Framework which stopped at netstandard2.0. I can't access any new api's unless they are exposed in a nuget package which supports netstandard2.0.

@geoffkizer
Copy link
Contributor

You mean like I requested in #15567 5 years ago before, 8 months before .NET Core 1.0 was released?

Yep, exactly :) Thanks for finding that issue.

@mconnew
Copy link
Member Author

mconnew commented Sep 21, 2020

I've confirmed it's fixed in a more recent build. Closing the issue.

@mconnew mconnew closed this as completed Sep 21, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 7, 2020
@karelz karelz added this to the 6.0.0 milestone Jan 26, 2021
@karelz karelz removed the untriaged New issue has not been triaged by the area owner label Oct 20, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants