oddsdk/ts-odd

Safari WebSocket connection: kNWErrorDomainPOSIX error

Opened this issue · 3 comments

bgins commented

Summary

Problem

Safari fails to establish a WebSocket connection with peers.

Impact

Data cannot be published or synced without a connected WebSocket.

Solution

Needs investigation.

Detail

Describe the bug

When authenticated and using a web app in macOS Safari, the console reports errors like:

WebSocket connection to 'wss://production-ipfs-cluster-us-east-1-node1.runfission.com:4003/p2p/12D3KooWNntMEXRUa2dNgkQsVgzao6zGSYxm1oAs83YtRy6uBuxv' failed: The operation couldn’t be completed. (kNWErrorDomainPOSIX error 100 - Protocol error)

To Reproduce
Steps to reproduce the behavior:

  1. Open an app in macOS Safari
  2. Open the developer tools to observe the error

Expected behavior

No error should be reported and file system operations that rely on peers should work.

Desktop (please complete the following information):

  • OS: macOS Ventura 13.3.1 (a)
  • Browser: Safari version 16.4 (18615.1.26.110.1)
bgins commented

@therealjeffg found a report that likely attributes the error to the NSURLSession WebSocket implementation in Safari: https://bugs.webkit.org/show_bug.cgi?id=228296#c18

@avivash and @bgins have confirmed that when NSURLSession Websocket is disabled, the error goes away. This feature can be turned off by unchecking NSURLSession Websocket in Develop -> Experimental Features.

Pushing this issue to the control pod - it's likely a server side fix

bgins commented

A bit more detail on how we may be able to mitigate this issue. From the thread above: https://bugs.webkit.org/show_bug.cgi?id=228296#c18

I've encountered this issue too with a WebSocket server using HTTP/2 + TLS 1.3. The connection succeeds at first and I'm able to send and receive some (short) WebSocket messages, but then the connection gets disconnected with the aforementioned "kNWErrorDomainPOSIX error 100 - Protocol error" error message. A longer message sent by the server seems to cause the disconnection.

The root issue is likely a Safari bug, but we may be able to work around it.