cocos2dx 3.15 Native 的wss不好用啊...

web版本能连上,Native 版不行

这是咋啦?

D/WebSocket.cpp (567): after join ws thread

正在连接到服务器: wss://test.xx.xxxx.xx/game/

D/WebSocket.cpp (415): WebSocket thread start, helper instance: 08451F10

D/WebSocket.cpp (167): NOTICE: Initial logging level 911

D/WebSocket.cpp (167): NOTICE: Libwebsockets version: 2.1.0 desktop-8c9aqu5\cocosengine@DESKTOP-8C9AQU5-v3.4-141-gcddc296

D/WebSocket.cpp (167): NOTICE: IPV6 not compiled in

D/WebSocket.cpp (167): NOTICE: libev support not compiled in

D/WebSocket.cpp (167): NOTICE: libuv support not compiled in

D/WebSocket.cpp (167): NOTICE: Threads: 1 each 30000 fds

D/WebSocket.cpp (167): NOTICE: Compiled with OpenSSL support

D/WebSocket.cpp (167): NOTICE: mem: per-conn: 392 bytes + protocol rx buf

D/WebSocket.cpp (873): scheme: wss, host: test.dz.01cs.cc, port: 0, path: /fk/game/

D/WebSocket.cpp (837): WARNING: CA Root file isn’t set. SSL connection will not peer server certificate

D/WebSocket.cpp (167): NOTICE: Creating Vhost ‘default’ port -1, 1 protocols, IPv6 off

D/WebSocket.cpp (167): NOTICE: lws_protocol_init

D/WebSocket.cpp (1322): WebSocket (087B8850) Unhandled websocket event: 32

D/WebSocket.cpp (1322): WebSocket (087B8850) Unhandled websocket event: 29

D/WebSocket.cpp (167): ERR: server’s cert didn’t look good, X509_V_ERR = 20: error:00000014:lib(0):func(0):reason(20)

D/WebSocket.cpp (1197): WebSocket (087B8850) onConnectionError, state: 0 …

D/WebSocket.cpp (1226): WebSocket (087B8850) onConnectionClosed, state: 2 …

D/WebSocket.cpp (1256): onConnectionClosed, WebSocket (087B8850) is closing by server.

D/WebSocket.cpp (1279): WebSocket (087B8850) onConnectionClosed DONE!

D/WebSocket.cpp (1322): WebSocket (087B8850) Unhandled websocket event: 45

D/WebSocket.cpp (1322): WebSocket (087B8850) Unhandled websocket event: 33

D/WebSocket.cpp (1226): WebSocket (087B8850) onConnectionClosed, state: 3 …

onerror
D/WebSocket.cpp (744): closeAsync: WebSocket (087B8850) is closing…

D/WebSocket.cpp (748): closeAsync: WebSocket (087B8850) was closed, no need to close it again!

设置证书了么?

怎么设置?浏览器的可以直接连啊
能否给个例子?谢谢

引擎不是浏览器啊,使用libwebsockets库做wss连接是需要用证书的。

看看WebSocket的测试例啊。

    if (!_wsiSendText->init(*this, "wss://echo.websocket.org", &protocols, "cacert.pem"))
    {
        CC_SAFE_DELETE(_wsiSendText);
    }

如果证书过期了呢?换客户端?还是热更?

cacert.pem 这个文件是对应 wss://echo.websocket.org 这个地址的?
在哪下载的?

http://discuss.cocos2d-x.org/t/websocket-supports-ssl-connections/34611

CA Root file could be exported from your browser or just use which in curl
(http://curl.haxx.se/ca/cacert.pem)

1赞

3Q,已经解决

能帮忙看一下吗?
http://forum.cocos.com/t/cocos2dx-3-15-wss/53277