You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Failed connection will throw exception. If the source was cancellation, then it will be TaskCancelledException, otherwise different exception.
Does it help?
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 ;)
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.
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)
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.
Activity
karelz commentedon Dec 18, 2018
Failed connection will throw exception. If the source was cancellation, then it will be
TaskCancelledException, otherwise different exception.Does it help?
cosminstirbu commentedon Feb 1, 2019
It doesn't help that much, we would need to know what are the exceptions thrown in case of connection error, etc.
cspaniard commentedon Feb 21, 2019
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 commentedon 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
I'll schedule to do this on a future sprint
cspaniard commentedon Feb 21, 2019
Thanks @mairaw... I appreciate you looking into this issue.
These are the exceptions I get just by specifying a bad port:
Taking into account what you mentioned, I don't know how to solve this, but IMHO I think that at least
System.Net.WebSockets.WebSocketExceptionshould be in the docs (besides the one you pointed out)Again, thanks for looking into it...
David
JohBa commentedon Jun 4, 2019
So I fell over this recently.
We currently implement a mqtt client with the help of
MQTTnet, that usesSystem.Net.WebSockets(v4.3.0). After a few problems we decided to test some things withSystem.Net.WebSocketsitself and I'm a bit confused, to be honest.In our scenario we use
netcore2.2andnet461with the library, a simple call toConnectAsyncwith aCancellationTokenwith very small timeout. The exception we get onnetcore2.2and on
net461According to https://referencesource.microsoft.com/#System/net/System/Net/WebSockets/ClientWebSocket.cs,9503b6a5d6701068, which was referenced above, everything that is not a
WebExceptionis just thrown but inhttps://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