问题描述
我正在构建一个 Web 套接字服务器,但是,出于测试目的,我希望 Chrome 或 Firefox 或任何其他浏览器将消息分段发送,以便我可以测试我的实现.
I'm building a Web socket server, however, for testing purposes, I'd like Chrome or Firefox or any other browser to send the message fragmented so I can test my implementation.
我什至尝试过发送 100K 文本数据,但 FIN 标志始终设置为 1,操作码为 TEXT.
I've tried even sending 100K text data and the FIN flag is always set to 1 and the opcode is TEXT.
有没有办法手动触发碎片帧?有没有更灵活的客户?
Is there a way to manually trigger fragmented frames? Any client out there with more flexibility?
推荐答案
Javascript WebSocket API 不公开此选项.最近,当一些更现代的浏览器(Chromium 衍生产品)不可预测地发送碎片化的 WebSocket 帧时,我遇到了同样的挫折.
The Javascript WebSocket API does not expose this option. I recently ran into the same frustration when some more modern browsers (A Chromium derivative) was unpredictably sending fragmented WebSocket frames.
为了进行测试,我推出了自己的 TCP 客户端,发送预先计算好的碎片化 WebSocket 帧.不理想,但它完成了工作,而且 AFAIK 还没有其他选择.
For testing I rolled my own TCP client sending pre-calculated fragmented WebSocket frames. Not ideal, but it got the job done, and AFAIK there's no alternative yet.
这篇关于如何从客户端触发 websocket 帧碎片?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!