Skip to content

Safari workarounds - too long of JSON message, too frequently sent? #385

Closed
@kirsle

Description

@kirsle

I have a WebSocket chat room app that uses this module: https://github.com/kirsle/BareRTC and for a long time I am trying to figure out how to get Safari (on Mac OS Ventura, as well as iPhone/iPad) to like my app because currently disconnects happen a lot, to the point where users can't even get into the chat room to begin with. The WebSockets work OK on Chrome or Firefox on all device types tho (including Mac OS and Androids, but not iOS since all browsers there are Safari) -- it's only Safari on Ventura and iOS that doesn't like my chat room.

What I would see is Safari connects, sends its username, my server sends all the 'welcome messages' to various chat rooms, and this overwhelmed Safari somehow and it would promptly disconnect ("failed to read frame header: EOF" like it hung up the connection from the client side). I have seen in the Safari console it says: "protocol error" for the websocket, with no more useful info than that.

I did some poking today and some leads I found so far are one of two things:

  • If I removed all my welcome messages so that Safari doesn't receive too much upon connecting, it's able to log in and chat OK.
  • If "too long" of a message is sent, Safari will disconnect - I can do this by just copy/pasting a message until it's, idk 500 characters long - it's really not a huge threshold but once something that long comes back across the WebSocket, Safari hangs up immediately.
  • I also wonder if too rapid of messages trips it too - I've tried putting in timeouts and queues to only send a WS message once every 100ms-1s at most to Safari, but I haven't found if this makes an impact at all.

The most reliable way to disconnect Safari is just to send a "long" chat message; I think in my welcome messages, some of them listed some basic rules for my chat room, maybe only 500-1000 characters and that would disconnect Safari too. If I remove all welcome messages, Safari works until somebody says too much in chat and then it hangs up!

Has anyone encountered things like this and have ideas for workarounds? Unfortunately I own no Apple hardware to test on, I was able to get a Ventura VM going with OSX-KVM to at least see about desktop Safari.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions