Skip to content

Instantly share code, notes, and snippets.

@pizzaboxer
Last active October 29, 2024 21:39
Show Gist options
  • Select an option

  • Save pizzaboxer/4b58303589ee5b14cc64397460a8f386 to your computer and use it in GitHub Desktop.

Select an option

Save pizzaboxer/4b58303589ee5b14cc64397460a8f386 to your computer and use it in GitHub Desktop.
Documentation of .NET connectivity errors
  • Type: System.Net.Http.HttpRequestException
  • Message: No connection could be made because the target machine actively refused it.
  • HRESULT: 0x80004005
  • Inner Exception:
    • Type: System.Net.Sockets.SocketException
    • Message: Ditto
    • Error code: 10061 (WSAECONNREFUSED)
  • Notes: Likely firewall caused, can be invoked by making a request to a host on a port that's not open or active

  • Type: System.Net.Http.HttpRequestException
  • Message: The requested name is valid, but no data of the requested type was found.
  • HRESULT: 0x80004005
  • Inner Exception:
    • Type: System.Net.Sockets.SocketException
    • Message: Ditto
    • Error code: 11004 (WSANO_DATA)
  • Notes: Can be invoked if the domain in question is configured in hosts to point to 0.0.0.0

  • Type: System.Net.Http.HttpRequestException
  • Message: Response status code does not indicate success.
  • HRESULT: 0x80131500
  • Inner Exception: null
  • Notes: Invoked when HttpResponseMessage.EnsureSuccessStatusCode() is called on an errored response

  • Type: System.Threading.Tasks.TaskCanceledException
  • Message: A task was canceled.
  • HRESULT: 0x8013153B
  • Inner Exception: null
  • Notes: Happens when the time spent waiting for a response exceeds the defined HttpClient timeout period. Can be simulated if you set the timeout to 1 millisecond or something. Will likely be the most common error you face in production as a firewall or poor connection will typically cause this.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment