Failed to send WebSocket frame

Hello all,

Since recently, I have issues with websockets … I don’t know what has changed recently?! Maybe the issue was there since a while but I’m pretty sure I would have noticed before. It seems the issue happens more and more often lately!

I have the same issue on at least two versions of Meteor with similar codebase:

One old version METEOR@ with these DDP packages:


And also one more recent METEOR@ with these DDP packages:


The code base for both is very similar. The installation that is still on hasn’t changed much in the last months (beside some re-builds) and the is the active development branch.

Using Safari on iPad on IOS 10.3.1, I get the following error in the client’s console very repeatedly (3 to 4 times per second for many minutes) – the ID after sockjs changes each time:

WebSocket connection to 'wss://' failed: Failed to send WebSocket frame.

doSend — sockjs-0.3.4.js:1292
send — sockjs-0.3.4.js:1222
send — stream_client_sockjs.js:50
_send — livedata_connection.js:1040
sendMessage — livedata_connection.js:433
(anonymous function) — livedata_connection.js:1667
forEach — underscore.js:149
_sendOutstandingMethods — livedata_connection.js:1666
onReset — livedata_connection.js:354
(anonymous function) — stream_client_sockjs.js:81
forEach — underscore.js:149
_connected — stream_client_sockjs.js:81
onopen — stream_client_sockjs.js:167
dispatchEvent — sockjs-0.3.4.js:87
_dispatchOpen — sockjs-0.3.4.js:1060
_didMessage — sockjs-0.3.4.js:1125
onmessage — sockjs-0.3.4.js:1277

Then, after 20 minutes, it finally fails for real and the application gets back to its normal state. It gives the following message when it fails for real:

Error invoking Method 'server_AddToFeed': Internal server error [500]

I get the following on my server’s console, in a “catch”:

WriteError({"code":11000,"index":0,"errmsg":"insertDocument :: caused by :: 11000 E11000 duplicate key error index: devjf.Feeds.$_id_ dup key: { : ObjectId('14d580b5edecc4352e54b17e') }","op":{"createdAt":"2017-04-13T21:14:32.037Z","eventType":68,"_id":"14d580b5edecc4352e54b17e"}})

The code from where the problem is triggered is very simple:

try {
        createdAt: new Date(),
        eventType: pEventNumericalType
}  catch (error) {
    console.log('error inserting feed: ' + error);

I do numerous other inserts elsewhere in the code and the issue never happened with the other inserts.

In the duplicate error above, it is true that the inserted _id was a duplicate because it had already been inserted a tenth of a second before the flood of “re-add”. It looks like something is trying to re-add the same database entry over and over (which triggers duplicate detection in MongoDB).

It happens in various environments. On a remotely hosted server (Amazon) over https (wss) but I can also make it bug when connecting on a Meteor running on my laptop over http (ws).

Until I understand what the issue is, I needed to DISABLE_WEBSOCKETS=1 which solved everything …

Anyone has an idea?



Hey there, wanted to let you know that you aren’t alone, i’m running into this issue as well, specifically on iOS 10.3.x. I’ve also tested the beta versions of 10.3.2 and it occurs there as well.

I can confirm that this happens an multiple webservers, but also on my localhost. For me, I can trigger it when I update a document using $set with a base64 string that represents a signature. Hopefully i’ll be able to find out more soon…

1 Like

Update, looks like this might be the bug:

1 Like

We are having the same problem @thsowers, but ours occurs on subscription/publish too. Have you found some way to workaround it?

Same issue with METEOR@ on safari 10.1 (macOS):

WebSocket connection to 'ws://...:3000/sockjs/830/ncjlncy3/websocket' failed: Failed to send WebSocket frame.

but Fixed with Safari Technology Preview

It looks like some folks on the webkit bug thread have managed to temporarily circumvent this by limiting the size of transactions to 5,000 bytes:

Our product is called Awingu and we emailed all of our customers warning them not to update to the latest Safari. Because of this, we only had to patch one customer environment with a fix that limits the package size to around 5000 bytes.

But as @julienmalige mentioned, the fix has made it into Safari Technology Preview and should hopefully be making it’s way into iOS shortly :smile:


How can you limit the size of transactions?

Yes, thanks for the help, but I still don’t know how to limit the size of transactions in meteor, same as @webmagnets.

@renanccastro @webmagnets

I’m afraid I can’t speak generally to this, but the problem in my application was trying to send an $update over the server that contained a long base64 string, certainly over 5,000 bytes.

I could take the time send the message over in chunks, but i’m honestly just waiting for Apple to get their stuff together and patch so I don’t have to waste more client time on this issue

I suppose you could truncate messages to the server with hooks using something like ? It’s hard to say without knowing your app.

Did you try to temporarily disable websockets to see if it helped?


1 Like

Here is the revision which seems to fix the issue:

Fixed WebSocket.send (r215102) –

Not sure when it will be pushed to IOS though …

1 Like

Hi, thanks for all your replies information, it was very useful for us.
Does someone knows how to follow the iOS next release and how to be updated of which features are going to be included?

Thanks in advance!

Just tested IOS 10.3.2 and the webkit bug is still there … grrr


Webkit bug still in there, however deploying with DISABLE_WEBSOCKETS=1 does indeed work.

Hi all, I might have good news?! :thinking:

I can’t seem to reproduce the bug with IOS 10.3.3 which has the following user-agent:

Mozilla/5.0 (iPad; CPU OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60

While I still can easily reproduce the bug with IOS 10.3.2 which has the following user-agent:

Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_2 like Mac OS X) AppleWebKit/603.2.4 (KHTML, like Gecko) Mobile/14F89

And I can also reproduce the bug on OS X Safari 10.1.1 (12603.2.4) which has the following user-agent:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_5) AppleWebKit/603.2.4 (KHTML, like Gecko) Version/10.1.1 Safari/603.2.4

Anyone can confirm everything looks good with IOS 10.3.3 ??


OS X 10.12.6 – Safari 10.1.2 (12603.3.8) – also seems good. Here is its user-agent:

Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/603.3.8 (KHTML, like Gecko) Version/10.1.2 Safari/603.3.8



I can confirm your finding that with IOS 10.3.3 the bug seems to be FIXED.

With Meteor Cordova App for IOS 10.3.2 I could easily and reliably reproduce the bug over and over.

I just updated to 10.3.3 and tested the same thing and there was NO ISSUE.

10.3.2 - UNRELIABLE FOR WEBSOCKET USAGE. Can’t believe this what a bad issue. I feel sorry for my customers who had an unreliable experience with my software. :frowning:

10.3.3 - FIXED… NO WEBSOCKET ISSUE. :relieved:

TESTED USING CORDOVA APP. Would be good if others can confirm to so we have further data to indicate that yes indeed the bug has been resolved.