简体   繁体   English

Socket.io引发“ TypeError:无法读取未定义的属性'push'”

[英]Socket.io raises “TypeError: Cannot read property 'push' of undefined”

I am using socket.io for communicating between two servers. 我正在使用socket.io在两个服务器之间进行通信。 The problem is that after I updated the socket.io package to the last version, an issue regarding to this package persists: 问题是,在我将socket.io软件包更新到最新版本后,与该软件包有关的问题仍然存在:

  1. https://www.dropbox.com/s/olficgz43zqr39e/Screenshot%202016-10-26%2018.51.11.png?dl=0 https://www.dropbox.com/s/olficgz43zqr39e/Screenshot%202016-10-26%2018.51.11.png?dl=0

  2. https://www.dropbox.com/s/5w92uq10ao94t84/Screenshot%202016-10-26%2018.51.34.png?dl=0 https://www.dropbox.com/s/5w92uq10ao94t84/Screenshot%202016-10-26%2018.51.34.png?dl=0

The error of the module: 模块错误:

"Cannot read property 'push' of undefined" -> socket.io -> this.sendBuffer.push(packet) -> LINE: 155.

The issue is regarded to socket.io-client package, and the path of the second screen is: 该问题与socket.io-client软件包有关,第二个屏幕的路径为:

socket.io-client/lib/socket.js

Did anyone had this issue regarding the socket.io package before? 以前有没有人遇到关于socket.io包的问题?

Finally fixed it. 终于解决了。 If you're trying to communicate between those packages, make sure you work on the same versions for both of them. 如果您试图在这些软件包之间进行通信,请确保为它们使用相同的版本。 If not, some errors could appear, like the error that I wrote above. 如果没有,可能会出现一些错误,例如我上面写的错误。 I updated both packages (socket.io-client - for the front, and socket.io - for the api), and now it works. 我更新了两个软件包(socket.io-client-用于前端,socket.io-用于api),现在它可以工作了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Socket.io 未捕获类型错误:无法读取未定义的属性“应用” - Socket.io Uncaught TypeError: Cannot read property 'apply' of undefined Socket.io TypeError:无法读取未定义的属性“hteam” - Socket.io TypeError: Cannot read property 'hteam' of undefined Socket.io - UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'emit' of undefined - Socket.io - UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'emit' of undefined Socket.IO TypeError:无法读取未定义的属性“发出” - Socket.IO TypeError: Cannot read property 'emit' of undefined 当socket.io发出“登录”消息时,TypeError:无法读取未定义的属性“ navigate” - When socket.io emits to 'login', TypeError: Cannot read property 'navigate' of undefined AngularJS Socket.io:无法读取未定义的属性“ emit” - AngularJS Socket.io: Cannot read property 'emit' of undefined Karma无法读取未定义的socket.io的属性'prototype'? - Karma Cannot read property 'prototype' of undefined socket.io? Socket.io:“无法读取未定义的属性'emit'” - Socket.io : “Cannot read property 'emit' of undefined” Node.js和Socket.io-无法读取未定义的属性“ on” - Node.js & Socket.io - Cannot read property 'on' of undefined vue-socket.io 未捕获的类型错误:无法读取未定义的属性 - vue-socket.io Uncaught TypeError: Cannot read property of undefined
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM