[]WebSocket connection to 'ws://192.168.0.8:8102/' failed: Invalid frame header

一开始连接正常,密集发送消息到服务器后,就会给服务器程序发送关闭连接的信息。WebSocket connection to 'ws://192.168.0.8:8102/' failed: Invalid frame header
WebSocket connection to 'ws:// 103.37.44.105:8102/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
 
有朋友遇到过这类问题吗?
这是什么情况,有什么解决办法没 :(
已邀请:

faith_leaf

赞同来自:

已经确定问题,可以检查服务器端发送给客户端的包体大小是否超过 65535 

Aar0n

赞同来自:

这个要么就是服务器的问题,要么就是前端代码的问题。

faith_leaf

赞同来自:

搜索到一些资料,说是字节长度问题。
  • How long are the message you are trying to send If it's larger than 125 bytes you need to encode the length in a different manner i.e you must take the extended payload length into consideration. – Cyclonecode Jul 7 '15 at 10:22
  •  Right, of course, so i need to use the next two (or eight) bytes to store the length instead – BenJacob Jul 7 '15 at 10:25
  •  If the length is between 15 and 65535 bytes then your will have to add a two byte extended length, while if it's larger than 65535 bytes than you'll need a 4 byte extended length. – Cyclonecode Jul 7 '15 at 10:25
  • 1Checkout tools.ietf.org/html/rfc6455, you also have an example here on how to encode your header based on the payload size (this is an php example) github.com/CycloneCode/WSServer/blob/master/src/WSServer.php – Cyclonecode Jul 7 '15 at 10:26
  •  Here is another example: stackoverflow.com/questions/8125507/… – Cyclonecode Jul 7 '15 at 10:29

该问题目前已经被锁定, 无法添加新回复

商务合作
商务合作