[Solved] WWS not working in cocos

Options
no1no
no1no
edited May 2018 in JavaScript and TypeScript
Edit: Never mind, it turns out we need a file named cacert.pem to make it work.

Basically we're using Photon JS SDK with coco2d-x for our web client and then also use it to build for Android. The code is mostly the same and it's working on the web as well on Android. Except only ws is working. I suspect cocos2d-x doesn't support wss. But I've tried testing wss using a test website wss://echo.websocket.org:443 it seem wss is supposed to be working fine. So I'm confused not sure why Photon SDK doesn't work with wss.

Here is the log when I'm trying to connect (9090 is the port I'm using for wss):

Master: PhotonPeer[_onConnecting] - Starts connecting wss://my website:9090 ..., raising "connecting" event ...
D/WebSocket.cpp (415): WebSocket thread start, helper instance: 0x60c0002b1a00
D/WebSocket.cpp (167): NOTICE: Initial logging level 911

D/WebSocket.cpp (167): NOTICE: Libwebsockets version: 2.1.0 james@James-Chen.local-v3.4-139-gbdcf7f8

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

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 4864 fds

D/WebSocket.cpp (167): NOTICE: mem: platform fd map: 38912 bytes

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

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

D/WebSocket.cpp (873): scheme: wss, host: my website, port: 9090, path:
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 on

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

D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) Unhandled websocket event: 32
D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) 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 (0x7fd438eacfd0) onConnectionError, state: 0 ...
D/WebSocket.cpp (1226): WebSocket (0x7fd438eacfd0) onConnectionClosed, state: 2 ...
D/WebSocket.cpp (1256): onConnectionClosed, WebSocket (0x7fd438eacfd0) is closing by server.
D/WebSocket.cpp (1279): WebSocket (0x7fd438eacfd0) onConnectionClosed DONE!
D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) Unhandled websocket event: 45
D/WebSocket.cpp (1322): WebSocket (0x7fd438eacfd0) Unhandled websocket event: 33
D/WebSocket.cpp (1226): WebSocket (0x7fd438eacfd0) onConnectionClosed, state: 3 ...
ERROR : Master: PhotonPeer[_onError] - Connection error: {"type":"error"}
Client: State: ConnectingToMasterserver -> Error
ERROR : Client: Error: 1001 Master peer error
Client: State: Error -> Disconnected
Master: onclose: wasClean = , code= , reason =
Master: PhotonPeer[_onDisconnect] - Socket closed, raising "disconnect" event ...
D/WebSocket.cpp (545): In the destructor of WebSocket (0x7fd438eacfd0)
D/WebSocket.cpp (565): before join ws thread
D/WebSocket.cpp (167): NOTICE: lws_context_destroy

D/WebSocket.cpp (425): WebSocket thread exit, helper instance: 0x60c0002b1a00
D/WebSocket.cpp (567): after join ws thread

Note that I checked the server log and don't see any connection request.
This discussion has been closed.