BLWebSocketsServer icon indicating copy to clipboard operation
BLWebSocketsServer copied to clipboard

Safari closes connection on large messages with x-webkit-deflate-frame

Open BlackWolf opened this issue 9 years ago • 2 comments

I noticed today that sending large messages (e.g. 100.000 bytes) to a BLWebSocketsServer from a Safari browser (either iOS or Desktop) causes a close on the connection.

This behaviour does not happen with other browsers (e.g. Chrome) and stops immediately once I comment out the x-webkit-deflate-frame extension in extension.c. I am not really a websocket expert and unsure if this is an issue with BLWebSocketsServer or with libwebsocket.

To test, you can create a simple echo server and then use this code (with adjusted IP and PORT):

<html>
<body>
<script>

function log(msg) {
  document.getElementsByTagName("body")[0].innerHTML += msg+"<br/>";
}

var websocket       = new WebSocket("ws://IP:PORT");
websocket.onopen    = function() {
  log("Open");

    var x = "";
    for( var i=0; i < 100000; i++ )
        x += "x";
    log("Sending "+x.length+" bytes.");
    websocket.send(x);
};
websocket.onclose   = function(e) {
  log("Close ("+e.code+")");
};

</script>
</html>

The result in Chrome is:

Open
Sending 100000 bytes.

The result in Safari is:

Open
Sending 100000 bytes.
Close (1006)

BlackWolf avatar Feb 12 '15 22:02 BlackWolf

This is probably related to libwebsocket.

benlodotcom avatar Feb 25 '15 07:02 benlodotcom

I suppose so as well, still it might be better to disable the extension by default, as I pretty much only found the cause of the issue by accident, it's really hard to debug as Safari doesn't give any meaningful reason for closing the socket

BlackWolf avatar Feb 25 '15 08:02 BlackWolf