简体   繁体   English

带有node.js的binaryjs的websocket有效负载的开销

[英]Overhead in websocket payload for binaryjs with node.js

I have implemented an application which sends multimedia content via websocket. 我已经实现了一个通过websocket发送多媒体内容的应用程序。 I've observed, by analysing the traffic with wireshark, that the payload sending the same content with http and websocket differs. 通过观察Wireshark的流量,我观察到,使用http和websocket发送相同内容的有效负载有所不同。 For websocket, the payload is always exactly 6 bytes larger than for http. 对于websocket,有效负载始终总是比http大6个字节。 (The headers are obviously completely different, what is clear.) (标题显然完全不同,这很清楚。)

I implemented it on javascript using Node.js with the module binaryjs on the server. 我使用Node.js和服务器上的模块binaryjs在JavaScript上实现了它。

Either Node.js or binaryjs library adds 5 bytes at the beginning of the multimedia data (it looks like 0x93 0x02 0xda 0x5e 0xcb) and 1 more byte at the end of it (it looks like 0x15). Node.js或binaryjs库都在多媒体数据的开头添加了5个字节(看起来像0x93 0x02 0xda 0x5e 0xcb),在它的结尾又增加了1个字节(看起来像0x15)。 Any idea where this overhead may come from? 知道这笔开销可能来自哪里吗?

As robertklep said the overhead you mention is because of metadata. 正如robertklep所说,您提到的开销是由于元数据造成的。 binarypack which is used by binaryjs in serializing/deserializing (or packing/unpacking) binary data adds those bytes. BinaryJS在对二进制数据进行序列化/反序列化(或打包/解压缩)时使用的binarypack将这些字节加起来。 binarypack uses much of messagepack specs and adds a few extra. binarypack使用了许多messagepack规范,并增加了一些额外的功能。

The function likely adding those extra bytes is pack_bin which works for binary files. 可能添加这些额外字节的函数是pack_bin ,它适用于二进制文件。 You can see that here . 您可以在这里看到。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM