When trying to create a WebSocket object in WebKit using : new WebSocket('ws://[::1]:8080') An error will be raised : "WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 2.)" It will do the same for every IPv6 address. It will also break if brackets [ ] are removed.
<rdar://problem/9977173>
Confirmed with Safari 5.1.
Note : WebSocket will work properly if used with domain name (example.com) bound to ipv6 only. Then problem must come from address parsing.
I cannot reproduce this problem. It seems fixed, can anyone confirm that?
We are experiencing similar issues right now: WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 1.) What is the current state of this issue?
I am experiencing this problem in Safari Technical Preview 15.4, release 135. In my case, attempting to open a WebSocket connection to a server with a literal IPv6 address fails with WebSocket network error: The operation couldn’t be completed. (kCFErrorDomainCFNetwork error 1.) The address is ws://[::]:3589, which Chrome connects to without error. Safari succeeds when I use the equivalent IPv4 address, ws://localhost:3589. The reason I ran into this is that I am attempting to debug a web application on my iPhone. I am serving the application from my laptop, which is connected to my phone via a USB personal hotspot. This hotspot only assigns my laptop an IPv6 address. I do not think I can alter my phone's /etc/hosts file to give my laptop's IPv6 address a domain name, so I am forced to use an IPv6 URL.
Take a look at this issue: https://bugs.webkit.org/show_bug.cgi?id=233752 Is yours also resolved in iOS 15.4 Beta 2
I will check next time I have access to a modern iPhone. In the meantime, upgrading STP to release 139 did not resolve the issue. I noticed that I needed to add a '1' to my IPv6 URL for Chrome to consider it a secure origin: http://[::1]:3589. This did not help with Safari, but it got me thinking that maybe WebKit is rejecting [::] and [::1] as insecure.
I just read your issue again. My issue has something to do with the introduction iCloud Private Relay and the adoption of the Network layer in iOS. Your issue predates that change. You may try to checkout this comment regarding the Safari development flags: https://bugs.webkit.org/show_bug.cgi?id=233752#c3
Comment 0 seems to work fine today.
I can confirm this is working in Safari v16.4 on MacOS.