英文:
Can a websocket message be intentionally split?
问题
我正在处理一个服务器,并完成了握手和基本的WebSocket解码函数(服务器是Go语言编写的!)。我想知道如何测试我的分片处理代码。是否可以使用Chrome创建一个WebSocket连接到我的本地服务器,然后将"hello"拆分成两个帧进行测试?我已经成功发送了"hello"并在服务器上看到了它。发送两次"hello"只是两个带有FIN位的消息。
英文:
I am working on a server and finished the handshake and basic websocket unmasking functions (the server is go!). I am wondering how I could test my fragment handling code. Is there a way to, with chrome, create a websocket, connect to my local server, and then split "hello" into 2 frames. I was able to send "hello" and see it on the server. Sending hello twice was just 2 messages with fin bits.
答案1
得分: 1
Gorilla客户端在消息大小大于写缓冲区大小时发送分段消息。
AutoBahn测试套件包括对分段消息的测试。您可以使用Gorilla用于Autobahn的测试服务器作为测试的起点。
另一个选择是使用经过测试的Gorilla websocket包而不是编写自己的websocket代码。
英文:
The Gorilla client sends fragmented messages when the message size is greater than the write buffer size.
The AutoBahn Test Suite includes tests for fragmented messages. You can use the Gorilla test server for Autobahn as a starting point for your tests.
Another option is to use the tested Gorilla websocket package instead of writing your own websocket code.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论