websocket与服务端握手会报握手不成功的错误解决方法:
首先是服务端首次收到请求要回报给客户端的报文要做处理多的不说,方法敬上:
1 /// <summary> 2 /// 打包请求连接数据 3 /// </summary> 4 /// <param name="handShakeBytes"></param> 5 /// <param name="length"></param> 6 /// <returns></returns> 7 private byte[] PackageHandShakeData(byte[] handShakeBytes, int length) 8 { 9 string handShakeText = Encoding.UTF8.GetString(handShakeBytes, 0, length); 10 string key = string.Empty; 11 Regex reg = new Regex(@"Sec\-WebSocket\-Key:(.*?)\