Skip to content

Failed Connections #1431

Open
Open

Description

@londospark

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.

Activity

  1. added
    untriaged
    on Dec 18, 2018
  2. karelz commented on Dec 18, 2018

    @karelz
    Member

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

  3. cosminstirbu commented on Feb 1, 2019

    @cosminstirbu

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

  4. cspaniard commented on Feb 21, 2019

    @cspaniard

    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 ;)

  5. mairaw commented on Feb 21, 2019

    @mairaw
    Contributor

    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

  6. reopened this on Feb 21, 2019
  7. added
    doc-enhancement
    Pri2
    and removed
    untriaged
    on Feb 21, 2019
  8. added this to the March 2019 milestone on Feb 21, 2019
  9. cspaniard commented on Feb 21, 2019

    @cspaniard

    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

  10. self-assigned this
    on Jun 4, 2019
  11. modified the milestones: March 2019, June 2019 on Jun 4, 2019
  12. JohBa commented on Jun 4, 2019

    @JohBa

    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

  13. modified the milestones: June 2019, Backlog on Sep 3, 2019
  14. removed their assignment
    on Mar 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Pri2area-System.Netdoc-enhancementdotnet-api/prod

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions