不好意思,明白了。之前不太会用
实测应该是没问题的,你再检查检查,确认是否是客户端发送失败,还是客户端发送成功但服务器没接收到?
我这边发了一个length是20万的字符串给到服务器。客户端显示发送成功:
![]()
从这个文档里面读取的字符串

服务器这边也确实是接收到了这些字符串

客户端代码:
var ws = new WebSocket("wss://www.zzxgame.com.cn:3000");
ws.onopen = function (event) {
console.log("Send Text WS was opened.");
cc.loader.loadRes("trackerui_czech", cc.TextAsset, (err,res) => {
console.log(res.text);
console.log("send message size :" , res.text.length);
ws.send(res.text);
});
};
ws.onmessage = function (event) {
console.log("response text msg: " + event.data);
};
ws.onerror = function (event) {
console.log("Send Text fired an error");
};
ws.onclose = function (event) {
console.log("WebSocket instance closed.");
};
服务端代码,nodejs弄的
var fs = require('fs');
var cfg = {
ssl: true,
port: 3000,
ssl_key: '3_zzxgame.com.cn.key',
ssl_cert: '2_zzxgame.com.cn.crt'
};
var httpServ = (cfg.ssl) ? require('https') : require('http');
var WebSocketServer = require('ws').Server;
var app = null;
var processRequest = function(req, res) {
res.writeHead(200);
res.end('All glory to WebSockets!\n');
};
if (cfg.ssl) {
app = httpServ.createServer({
key: fs.readFileSync(cfg.ssl_key),
cert: fs.readFileSync(cfg.ssl_cert)
}, processRequest).listen(cfg.port);
} else {
app = httpServ.createServer(processRequest).listen(cfg.port);
}
var wss = new WebSocketServer({
server: app
});
console.log("wss setup success, listend :" , cfg.port);
wss.on('connection', function(wsConnect) {
console.log("connected : a client come in");
wsConnect.on('message', function(msg) {
if (msg === undefined)
return;
console.log("message recived size :" , msg.length);
});
wsConnect.on('disconnect', function(mConnect) {
});
});
1赞
辛苦了亲,我再查一查
经查实,是我的netty WebSocket服务端接收数据有长度限制,超过一定长度接收失败,谢谢啦
引擎組的大神辛苦了…
CDN吧?
写脚本后自动修改(适合H5的)
哇 老铁。。原来时候服务区拒绝了。感觉这个是不是抓包就能看到 。毕竟c端发送成功了
我是mac开发环境,在mac下有什么抓包工具推荐吗?你们用什么抓包工具?
我是发现了很多服务器语言都有这个问题,之前我这边也是是服务器的长度限制了我不给发大数据,我们是用go的websocket
wireshark
感觉数据长度是是有问题, 我的头像是微信路径比较长,拉50条排行榜玩家记录都拉不下来,