admin管理员组文章数量:1023867
Getting this error when validating data received from the client through socket.io.
C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532
6:23:55 PM web.1 | if (!Validation.isValidUTF8(messageBuffer)) {
6:23:55 PM web.1 | ^
6:23:55 PM web.1 | TypeError: Cannot read property 'isValidUTF8' of undefined
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532:28
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:368:7
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\PerMessageDeflate.js:249:5
6:23:55 PM web.1 | at afterWrite (_stream_writable.js:355:3)
6:23:55 PM web.1 | at onwrite (_stream_writable.js:346:7)
6:23:55 PM web.1 | at WritableState.onwrite (_stream_writable.js:89:5)
6:23:55 PM web.1 | at afterTransform (_stream_transform.js:79:3)
6:23:55 PM web.1 | at TransformState.afterTransform (_stream_transform.js:54:12)
6:23:55 PM web.1 | at Zlib.callback (zlib.js:613:5)
[DONE] Killing all processes with signal null
6:23:55 PM web.1 Exited with exit code 1
Editing out this section of code in Receiver.js,
if (!Validation.isValidUTF8(messageBuffer)) {
self.error('invalid utf8 sequence', 1007);
return;
}
stops the error from occuring but I would prefer a better solution as I'd like to use NPM and can't be bothered to redo this every time an update occurs.
I have also tried installing utf-8-validate into the node_modules folder of socket.io with no success
Getting this error when validating data received from the client through socket.io.
C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532
6:23:55 PM web.1 | if (!Validation.isValidUTF8(messageBuffer)) {
6:23:55 PM web.1 | ^
6:23:55 PM web.1 | TypeError: Cannot read property 'isValidUTF8' of undefined
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532:28
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:368:7
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\PerMessageDeflate.js:249:5
6:23:55 PM web.1 | at afterWrite (_stream_writable.js:355:3)
6:23:55 PM web.1 | at onwrite (_stream_writable.js:346:7)
6:23:55 PM web.1 | at WritableState.onwrite (_stream_writable.js:89:5)
6:23:55 PM web.1 | at afterTransform (_stream_transform.js:79:3)
6:23:55 PM web.1 | at TransformState.afterTransform (_stream_transform.js:54:12)
6:23:55 PM web.1 | at Zlib.callback (zlib.js:613:5)
[DONE] Killing all processes with signal null
6:23:55 PM web.1 Exited with exit code 1
Editing out this section of code in Receiver.js,
if (!Validation.isValidUTF8(messageBuffer)) {
self.error('invalid utf8 sequence', 1007);
return;
}
stops the error from occuring but I would prefer a better solution as I'd like to use NPM and can't be bothered to redo this every time an update occurs.
I have also tried installing utf-8-validate into the node_modules folder of socket.io with no success
Share Improve this question edited Feb 28, 2017 at 2:36 Rayce Rossum asked Feb 28, 2017 at 2:02 Rayce RossumRayce Rossum 411 silver badge3 bronze badges 2- Could you solve it? I have the same problem – Marian Klühspies Commented Mar 28, 2017 at 14:01
- I have the same problem, plus it for anyone can help ^-^ – phan ngoc Commented Apr 3, 2017 at 1:29
3 Answers
Reset to default 4Just Install or run this mand and good to go:
npm install ws bufferutil utf-8-validate
I got this error in a NextJS app (13.0.1) using socket.io.
I solved installing webpack-node-externals
:
npm install webpack-node-externals --save-dev
And then adding to next.config.js
:
const nodeExternals = require('webpack-node-externals');
module.exports = withBundleAnalyzer({
webpack(config) {
config.externals = [nodeExternals()];
return config;
},
...
});
It may not solve the OP case specifically, but may be useful for anyone having this issue with NextJS.
For those not using NextJS, adding the code below to webpack.config.js
should also work:
const nodeExternals = require('webpack-node-externals');
...
module.exports = {
...
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
...
};
UPDATE: upgrade ws
v2.x can fix this!
change Receiver.js in ws
module like this:
var isValidUTF8 = require('./Validation')
...
if (!isValidUTF8(messageBuffer)) {
...
}
you can do this just make it work, but it's not a good solution for this, it seems like that there is a wrong export of Validation module, you may send a PR to ws
to fix this.
Getting this error when validating data received from the client through socket.io.
C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532
6:23:55 PM web.1 | if (!Validation.isValidUTF8(messageBuffer)) {
6:23:55 PM web.1 | ^
6:23:55 PM web.1 | TypeError: Cannot read property 'isValidUTF8' of undefined
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532:28
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:368:7
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\PerMessageDeflate.js:249:5
6:23:55 PM web.1 | at afterWrite (_stream_writable.js:355:3)
6:23:55 PM web.1 | at onwrite (_stream_writable.js:346:7)
6:23:55 PM web.1 | at WritableState.onwrite (_stream_writable.js:89:5)
6:23:55 PM web.1 | at afterTransform (_stream_transform.js:79:3)
6:23:55 PM web.1 | at TransformState.afterTransform (_stream_transform.js:54:12)
6:23:55 PM web.1 | at Zlib.callback (zlib.js:613:5)
[DONE] Killing all processes with signal null
6:23:55 PM web.1 Exited with exit code 1
Editing out this section of code in Receiver.js,
if (!Validation.isValidUTF8(messageBuffer)) {
self.error('invalid utf8 sequence', 1007);
return;
}
stops the error from occuring but I would prefer a better solution as I'd like to use NPM and can't be bothered to redo this every time an update occurs.
I have also tried installing utf-8-validate into the node_modules folder of socket.io with no success
Getting this error when validating data received from the client through socket.io.
C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532
6:23:55 PM web.1 | if (!Validation.isValidUTF8(messageBuffer)) {
6:23:55 PM web.1 | ^
6:23:55 PM web.1 | TypeError: Cannot read property 'isValidUTF8' of undefined
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:532:28
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\Receiver.js:368:7
6:23:55 PM web.1 | at C:\Users\Rayce\Documents\SENG513\node-js-getting-started\node_modules\socket.io\node_modules\ws\lib\PerMessageDeflate.js:249:5
6:23:55 PM web.1 | at afterWrite (_stream_writable.js:355:3)
6:23:55 PM web.1 | at onwrite (_stream_writable.js:346:7)
6:23:55 PM web.1 | at WritableState.onwrite (_stream_writable.js:89:5)
6:23:55 PM web.1 | at afterTransform (_stream_transform.js:79:3)
6:23:55 PM web.1 | at TransformState.afterTransform (_stream_transform.js:54:12)
6:23:55 PM web.1 | at Zlib.callback (zlib.js:613:5)
[DONE] Killing all processes with signal null
6:23:55 PM web.1 Exited with exit code 1
Editing out this section of code in Receiver.js,
if (!Validation.isValidUTF8(messageBuffer)) {
self.error('invalid utf8 sequence', 1007);
return;
}
stops the error from occuring but I would prefer a better solution as I'd like to use NPM and can't be bothered to redo this every time an update occurs.
I have also tried installing utf-8-validate into the node_modules folder of socket.io with no success
Share Improve this question edited Feb 28, 2017 at 2:36 Rayce Rossum asked Feb 28, 2017 at 2:02 Rayce RossumRayce Rossum 411 silver badge3 bronze badges 2- Could you solve it? I have the same problem – Marian Klühspies Commented Mar 28, 2017 at 14:01
- I have the same problem, plus it for anyone can help ^-^ – phan ngoc Commented Apr 3, 2017 at 1:29
3 Answers
Reset to default 4Just Install or run this mand and good to go:
npm install ws bufferutil utf-8-validate
I got this error in a NextJS app (13.0.1) using socket.io.
I solved installing webpack-node-externals
:
npm install webpack-node-externals --save-dev
And then adding to next.config.js
:
const nodeExternals = require('webpack-node-externals');
module.exports = withBundleAnalyzer({
webpack(config) {
config.externals = [nodeExternals()];
return config;
},
...
});
It may not solve the OP case specifically, but may be useful for anyone having this issue with NextJS.
For those not using NextJS, adding the code below to webpack.config.js
should also work:
const nodeExternals = require('webpack-node-externals');
...
module.exports = {
...
target: 'node', // in order to ignore built-in modules like path, fs, etc.
externals: [nodeExternals()], // in order to ignore all modules in node_modules folder
...
};
UPDATE: upgrade ws
v2.x can fix this!
change Receiver.js in ws
module like this:
var isValidUTF8 = require('./Validation')
...
if (!isValidUTF8(messageBuffer)) {
...
}
you can do this just make it work, but it's not a good solution for this, it seems like that there is a wrong export of Validation module, you may send a PR to ws
to fix this.
本文标签: javascriptNodejs and Socketio UTF8 Validation TypeError coming from wsStack Overflow
版权声明:本文标题:javascript - Node.js and Socket.io UTF8 Validation TypeError coming from ws - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745568931a2156617.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论