WebSocket消息可以被有意地分割吗?

huangapple go评论83阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2017年4月28日 06:58:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/43669214.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定