使用node-v0.10.4进行websocket代理时出错“无效数据”

时间:2013-07-01 17:40:47

标签: javascript node.js proxy websocket

我使用node-v0.10.4来运行web-socket代理以连接到特定类型的服务器。但是在使用firefox浏览器(最新版本)通过代理建立连接后,我的终端中出现以下错误。终端显示错误:

net.js:595
throw new TypeError('invalid data');
      ^
TypeError: invalid data
at Socket.write (net.js:595:11)
at WebSocket.<anonymous> (/home/n-mol/Desktop/abs-master/wsproxy/wsproxy-tcp.js:69:10)
at WebSocket.EventEmitter.emit (events.js:98:17)
at Receiver.self._receiver.onbinary (/home/n-mol/node_modules/ws/lib/WebSocket.js:549:10)
at Receiver.opcodes.2.finish (/home/n-mol/node_modules/ws/lib/Receiver.js:448:14)
at Receiver.expectHandler (/home/n-mol/node_modules/ws/lib/Receiver.js:433:33)
at Receiver.add (/home/n-mol/node_modules/ws/lib/Receiver.js:93:24)
at Socket.firstHandler (/home/n-mol/node_modules/ws/lib/WebSocket.js:524:22)
at Socket.EventEmitter.emit (events.js:95:17)
at Socket.<anonymous> (_stream_readable.js:710:14)

以下一行Javascript代码出现在/home/n-mol/Desktop/abs-master/wsproxy/wsproxy-tcp.js:69:10

68. if (sock_ready) {
69.        sock.write(bytesView.buffer);
70.  } else ...

我想有一些兼容性问题,但我无法解决它。任何帮助将受到高度赞赏。提前谢谢。

1 个答案:

答案 0 :(得分:3)

试试这个......

if (sock_ready) {
  sock.write(new Buffer(bytesView));
} else

看起来Node开启了它在.10 vs .8中组装缓冲区的方式我也遇到了这个问题......即将向NDN-js提交拉取请求;)