Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在android的微信和qq浏览器访问,服务器报could not find handle invalid data package #19

Open
mozackye opened this issue Sep 20, 2015 · 2 comments

Comments

@mozackye
Copy link

我用最新的(0.1.4)pomelo-cocos2d-js 在android的微信和qq浏览器会连不上服务器,服务器报could not find handle invalid data package,其他浏览器和cocos运行正常,大概是因为pomelo-cocos2d-js的pomelo版本过低导致socket的数据包类型或格式不对,我服务器用的是pomelo1.1.9,我把模板的build.js放到客户端,这时候微信和qq浏览器访问就正常了,但我不知道怎么整合代码,也报pomelo-cocos2d-js中index.js第一句:
var Util = require('util');就报错:Error: can't open : No such file or directory 纠结啊

@gzw1217123
Copy link

楼主后来怎么解决的,我用的模板的build.js依旧报could not find handle invalid data package这个错

@zhang-z
Copy link

zhang-z commented Oct 9, 2017

我的情况类似,pomelo-cocos2d-js在node v8.1.3上运行时正常,在node v6.9.5上运行时服务器会报这个错误。摸索好久发现,node 6上(new Buffer(10)).buffer.byteLength === 8192,node 8上(new Buffer(10)).buffer.byteLength === 10

解决方案是把这一行socket.send(packet) (https://github.com/NetEase/pomelo-cocos2d-js/blob/master/dist/pomelo-cocos2d-js.js#L2871) 改成:

if (packet.length === packet.buffer.byteLength) {
  socket.send(packet.buffer)
} else {
  socket.send(packet)
}

Buffer, Uint8Array, Websocket.send 这几个还没仔细研究,总之这么改在我的环境里能运行

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants