【求助!多谢多谢!】
实时对战 sdk js 版
游戏开发引擎 cocos create 1.9.x
问题描述:
web 平台可以联网对战,打包 Android 后不行。
【特别说明】
之前遇到过这个问题,技术帮忙解决了,解决方式为,屏蔽掉设置证书的代码:
// if (cc.sys.platform === cc.sys.ANDROID) {
// const caPath = cc.url.raw("resources/cacert.pem");
// setAdapters({
// WebSocket: url => new WebSocket(url, null, caPath)
// });
// }
现在什么都没有改,在 Android 平台又不行了,是不是你们服务端修改了什么呢?
这次再次运行 demo 同样不行,你们那边运行 demo 应该也可以复现
log 信息:
08-01 10:38:51.697 32014-32267/org.cocos2d.helloworld D/JniHelper: JniHelper::getJavaVM(), pthread_self() = -821925600
08-01 10:38:51.703 32014-32076/org.cocos2d.helloworld D/jswrapper: JS: [DEBUG] {"server":"wss:\/\/cn-n1-cell4.leancloud.cn:5749\/","ttl":3600,"secondary":"wss:\/\/cn-n1-cell6.leancloud.cn:5749\/"}
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket thread start, helper instance: 0xe3ea39d0
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: Initial logging level 911
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: Libwebsockets version: 2.1.0 james@James-Chen.local-v3.4-139-gbdcf7f8
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: IPV6 compiled in and enabled
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: libev support not compiled in
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: libuv support not compiled in
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: Threads: 1 each 1024 fds
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: mem: platform fd map: 4096 bytes
08-01 10:38:51.705 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: Compiled with OpenSSL support
08-01 10:38:51.708 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: mem: per-conn: 376 bytes + protocol rx buf
08-01 10:38:51.725 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: scheme: wss, host: cn-n1-cell4.leancloud.cn, port: 5749, path: /
08-01 10:38:51.725 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WARNING: CA Root file isn't set. SSL connection will not peer server certificate
08-01 10:38:51.725 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: Creating Vhost 'default' port -1, 1 protocols, IPv6 on
08-01 10:38:51.726 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: NOTICE: lws_protocol_init
08-01 10:38:51.790 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) Unhandled websocket event: 32
08-01 10:38:51.790 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) Unhandled websocket event: 29
08-01 10:38:51.923 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: ERR: server's cert didn't look good, X509_V_ERR = 20: error:00000014:lib(0):func(0):reason(20)
08-01 10:38:51.924 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) onConnectionError, state: 0 ...
08-01 10:38:51.924 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) onConnectionClosed, state: 2 ...
08-01 10:38:51.924 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: onConnectionClosed, WebSocket (0xd13265e0) is closing by server.
08-01 10:38:51.924 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) onConnectionClosed DONE!
08-01 10:38:51.924 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) Unhandled websocket event: 45
08-01 10:38:51.924 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) Unhandled websocket event: 33
08-01 10:38:51.924 32014-32319/org.cocos2d.helloworld D/WebSocket.cpp: WebSocket (0xd13265e0) onConnectionClosed, state: 3 ...
08-01 10:38:51.940 32014-32076/org.cocos2d.helloworld D/jswrapper: JS: [DEBUG] 562388 : lobby -> open {"cmd":"session","op":"open","appId":"1yzaPvxYPs2DLQXIccBzb0k1-gzGzoHsz","peerId":"562388","sdkVersion":"0.18.0-beta.5","protocolVersion":0,"gameVersion":"0.0.1","i":1}
08-01 10:38:51.945 32014-32076/org.cocos2d.helloworld D/jswrapper: JS: [DEBUG] 562388 : lobby close
08-01 10:38:51.946 32014-32076/org.cocos2d.helloworld D/WebSocket.cpp: closeAsync: WebSocket (0xd13265e0) is closing...
08-01 10:38:51.946 32014-32076/org.cocos2d.helloworld D/WebSocket.cpp: closeAsync: WebSocket (0xd13265e0) was closed, no need to close it again!
08-01 10:38:51.966 32014-32076/org.cocos2d.helloworld D/jswrapper: JS: [DEBUG] 562388 : lobby closed