Skip to content

Failed Connections #1431

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

Open
londospark opened this issue Dec 18, 2018 — with docs.microsoft.com · 6 comments
Open

Failed Connections #1431

londospark opened this issue Dec 18, 2018 — with docs.microsoft.com · 6 comments
Labels
area-System.Net doc-enhancement Improve the current content dotnet-api/prod Pri2 Indicates issues/PRs that are medium priority
Milestone

Comments

Copy link

What do we expect on a failed connection? Would it be a cancelled Task or a faulted Task?


Document details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@dotnet-bot dotnet-bot added area-System.Net untriaged New issue has not been triaged by the area owner Source - Docs.ms labels Dec 18, 2018
@karelz
Copy link
Member

karelz commented Dec 18, 2018

Failed connection will throw exception. If the source was cancellation, then it will be TaskCancelledException, otherwise different exception.
Does it help?

@karelz karelz closed this as completed Dec 18, 2018
Copy link

It doesn't help that much, we would need to know what are the exceptions thrown in case of connection error, etc.

@cspaniard
Copy link

Wow...
This is not even close to being acceptable. How are we supposed to code if it is not documented what exceptions could be thrown ?

@karelz I really appreciate you answering, but nowhere in the documents or your comments tells us what is the failed connection exception thrown or any other error.

In the old MS Docs, the possible exceptions thrown by any object method were documented.

I will look in the old docs if I can find info on ClientWebSocket ;)

@mairaw
Copy link
Contributor

mairaw commented Feb 21, 2019

The content from the old MS docs were mostly all ported here @cspaniard - we're working on the last few migration issues. We don't usually document common exceptions that are caused by external factors instead of directly caused by the use of the API if that makes sense, such as network errors, IO errors, etc.

So for this API, we should document at least the following exceptions based on what I see here:
https://referencesource.microsoft.com/#System/net/System/Net/WebSockets/ClientWebSocket.cs,9503b6a5d6701068

  • ArgumentNullException
  • ArgumentException
  • ObjectDisposedException
  • InvalidOperationException
  • WebException
  • Exception

I'll schedule to do this on a future sprint

@mairaw mairaw reopened this Feb 21, 2019
@mairaw mairaw added doc-enhancement Improve the current content Pri2 Indicates issues/PRs that are medium priority and removed untriaged New issue has not been triaged by the area owner labels Feb 21, 2019
@mairaw mairaw added this to the March 2019 milestone Feb 21, 2019
@cspaniard
Copy link

Thanks @mairaw... I appreciate you looking into this issue.

These are the exceptions I get just by specifying a bad port:

System.Net.WebSockets.WebSocketException: Unable to connect to the remote server
System.Net.Http.HttpRequestException: Connection refused.
System.Net.Sockets.SocketException: Connection refused.

Taking into account what you mentioned, I don't know how to solve this, but IMHO I think that at least System.Net.WebSockets.WebSocketException should be in the docs (besides the one you pointed out)

Again, thanks for looking into it...

David

@mairaw mairaw self-assigned this Jun 4, 2019
@mairaw mairaw modified the milestones: March 2019, June 2019 Jun 4, 2019
@JohBa
Copy link

JohBa commented Jun 4, 2019

So I fell over this recently.
We currently implement a mqtt client with the help of MQTTnet, that uses System.Net.WebSockets (v4.3.0). After a few problems we decided to test some things with System.Net.WebSockets itself and I'm a bit confused, to be honest.
In our scenario we use netcore2.2 and net461 with the library, a simple call to ConnectAsync with a CancellationToken with very small timeout. The exception we get on netcore2.2

System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Threading.Tasks.TaskCanceledException: A task was canceled.

and on net461

System.Net.WebSockets.WebSocketException (0x80004005): Unable to connect to the remote server ---> System.Net.WebException: The request was aborted: The request was canceled.

According to https://referencesource.microsoft.com/#System/net/System/Net/WebSockets/ClientWebSocket.cs,9503b6a5d6701068, which was referenced above, everything that is not a WebException is just thrown but in
https://github.com/dotnet/corefx/blob/master/src/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs everything seems to be wrapped into a WebSocketException.

@matthid

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-System.Net doc-enhancement Improve the current content dotnet-api/prod Pri2 Indicates issues/PRs that are medium priority
Projects
None yet
Development

No branches or pull requests

9 participants