Bug 233943

Summary: NSURLSession WebSocket does not use the configured proxy
Product: WebKit Reporter: Andrea Govoni <smudge_docents.0z>
Component: Page LoadingAssignee: Nobody <webkit-unassigned>
Status: RESOLVED MOVED    
Severity: Normal CC: achristensen, beidson, cdumez, ggaren, youennf
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Mac (Intel)   
OS: macOS 12   
URL: https://ws.ifelse.io/.ws
Attachments:
Description Flags
WebSocket connection timeout errors in the JavaScript Console. none

Description Andrea Govoni 2021-12-07 11:41:38 PST
Created attachment 446214 [details]
WebSocket connection timeout errors in the JavaScript Console.

– Overview:
On macOS Monterey systems with configured Automatic Proxy Configuration (.pac) file or HTTP/HTTPS proxy servers, Safari doesn't use the proxy when establishing WebSocket connections if the experimental feature "NSURLSession WebSocket" is enabled (that is the default setting on Monterey).

– Steps to Reproduce:
1) Set a PAC file or HTTP/HTTPS proxy in System Preferences --> Network.
2) Go to https://ws.ifelse.io/.ws (that server is running https://github.com/jmalloc/echo-server according to this Stack Overflow question https://stackoverflow.com/questions/4092591/websocket-live-server).

– Actual Results:
On networks where Internet access is allowed only using the network proxy, the connection will not succeed and JavaScript Console will yield:
WebSocket connection to 'wss://ws.ifelse.io/' failed: The request timed out.

– Expected Results:
Safari should use the system proxy.

– Build Date & Hardware:
I've tested this issue on macOS Monterey 12.0.1 (21A559) with the following Safari builds:
• Safari 15.1 (17612.2.9.1.20) <-- current version on Monterey
• Safari Technology Preview release 135 (Safari 15.4, WebKit 17613.1.7.3)
• WebKit build archive r286598 <-- it actually threw a bunch of errors on startup and I was unable to test by disabling "NSURLSession WebSocket" because when I tried to open its Preferences to enable the Development menu, it crashed… so I'm not 100% sure about this test

– Additional Information:
If I disable the "NSURLSession WebSocket" experimental feature, system proxy is used and connections succeed.
Comment 1 Alex Christensen 2021-12-07 12:09:07 PST
Thank you for the report.  We are tracking this internally as rdar://84740185
Comment 2 Alexey Proskuryakov 2021-12-09 10:13:15 PST
Marking as MOVED per the above, as the fix will be below WebKit.