Skip to content

Each binary packet results in two packets, and two websocket frames #61

@darrachequesne

Description

@darrachequesne

As described here, currently:

socket.send('hello', new Buffer('1234'));
// results in the following packet
var packet = {
  type: 5,
  data: ['hello', <buffer>],
  nsp: '/',
  // id: <id> (if used with an acknowledgement)
};
// that gets encoded as two packets by socket.io-parser
[
  encodeAsString(packetWithoutBuffer),
  <buffer> 
]

The thing is, those two packets are sent as two different frames (here), which isn't really efficient (even if a websocket emit does not need a new TCP handshake).

One possible solution would be to concatenate those two packets in one buffer:

var stringPacket = encodeAsString(packetWithoutBuffer);
<stringPacket length><stringPacket as buffer><buffer> 

Yet that would be a breaking change, and a special case when handling binary data.

Related:

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