Web Socket issue in Safari/WebView on iOS 15/macOS Monterey

In our web app, we use the MQTT library which internally uses a WebSocket for communications. In iOS 14 and earlier it was working fine. But in iOS 15 and macOS Monterey, WebSocket breaks when we try to send the first message.

Below are some findings from our research:

  1. There is an experimental feature named NSURLSession WebSocket in Safari. This feature is by default enabled on iOS 15 and macOS Monterey. If we disable this feature, WebSocket seems to work fine.
  2. We have also noticed that when the above-mentioned experimental feature is enabled, it seems to add some limit on the size of the message that we can send from a socket connection. If we try to send messages of more than 84 bytes, the socket connection breaks. If we try to send messages of fewer than 84 bytes it works fine.

There are a few bugs related to NSURLSession WebSocket on WebKit Bugzilla… could it be this problem?

Bug 230962 – WebSocket connection terminated when server sends junk

Web Socket issue in Safari/WebView on iOS 15/macOS Monterey
 
 
Q