我使用node-v0.10.4运行web套接字代理来连接到特定类型的服务器。但在使用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 ...
我想有一些兼容性问题,但我无法解决。任何帮助都将不胜感激。提前谢谢。
试试这个。。。
if (sock_ready) {
sock.write(new Buffer(bytesView));
} else
看起来Node在.10和.8中改变了组装缓冲区的方式。我刚刚也遇到了这个问题。。。即将向NDNjs提交pull请求;)