runtime: ClientWebSocket.ConnectAsync() does not work on Mac

Description

in a simple MAUI test app, call to ClientWebSocket.ConnectAsync() on Mac does not return. some experimental work suggests that MAUI is defaulting to HttpNoProxy: when we don’t set proxy to ClientWebSocket Option the MAUI ClientWebSocket is defaulting to NoProxy and the connect fails. I checked the values of HttpClient.DefaultProxy: In MAUI app:

  HttpClient.DefaultProxy    {System.Net.Http.HttpNoProxy}

comparing that to .Net7 App, it’s set to MacProxy:

  HttpClient.DefaultProxy    {System.Net.Http.MacProxy}  

for reference: https://github.com/dotnet/dotnet/blob/main/src/runtime/src/libraries/System.Net.WebSockets.Client/src/System/Net/WebSockets/WebSocketHandle.Managed.cs#L35

in customer situation, WPAD (Web Proxy Auto-Discovery) is used to configure internal laptops. while testing on MS VPN, the code works. It’s worth considering whether the MS VPN proxy setup differs from WPAD,

we need to get Proxy Url/object into MAUI app for all different VPN configuration and create WebProxy object and set it to ClientWebSocket.

Steps to Reproduce

download the repro to Mac connected via VPN with WPAD configured. in the repro app, click on button to start test. the call to ClientWebSocket.ConnectAsync() will be stuck

Link to public reproduction project repository

https://github.com/linkaiyu/ClientWebSocket

Version with bug

7.0.49

Last version that worked well

Unknown/Other

Affected platforms

macOS

Affected platform versions

No response

Did you find any workaround?

short term workaround is to create a webproxy for the connection, but for long term when the app is going to be released to the public, the short term solution won’t meet the needs

Relevant log output

No response

About this issue

  • Original URL
  • State: open
  • Created a year ago
  • Comments: 23 (12 by maintainers)

Commits related to this issue

Most upvoted comments

@karelz , the console app works. the customer repro include a console app that uses the same code as in MAUI app. MAUI app fails. @mikeparker104

It would be good to get packet captures @linkaiyu and verify where this code is trying to connect to. AFAIK the discovery does not work on macOS e.g. you will either need to set the environment or use the system proxy config. It may be best to try very simple project with HttpCLient to peel off all the extra layers.