0

Have anyone use cocos2d js with deepstream io ?

I tried to use deepstream client js but it seem to be fail when try to connect server via network (websocket) :

this is adb log:

06-06 09:43:19.227: D/cocos2d-x debug info(26288): connectDeepStream [object Object] PlayerActions.login.request@assets/src/modules/Actions/Player.js:22:13,

06-06 09:43:19.232: D/WebSocket.cpp(26288): WebSocket thread start, helper instance: 0x97987760

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: Initial logging level 911

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: Libwebsockets version: 2.1.0 james@James-Chen.local-v3.4-139-gbdcf7f8

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: IPV6 compiled in and enabled

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: libev support not compiled in

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: libuv support not compiled in

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: Threads: 1 each 1024 fds

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: mem: platform fd map: 4096 bytes

06-06 09:43:19.237: D/WebSocket.cpp(26288): NOTICE: Compiled with OpenSSL support

06-06 09:43:19.247: D/WebSocket.cpp(26288): NOTICE: mem: per-conn:
376 bytes + protocol rx buf

06-06 09:43:19.247: D/WebSocket.cpp(26288): protocol: ws, host: ...*, port: 3512, path: deepstream

06-06 09:43:19.247: D/WebSocket.cpp(26288): NOTICE: Creating Vhost 'default' port -1, 1 protocols, IPv6 on

06-06 09:43:19.252: D/WebSocket.cpp(26288): NOTICE: lws_protocol_init

06-06 09:43:19.252: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) Unhandled websocket event: 32

06-06 09:43:19.252: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) Unhandled websocket event: 29

06-06 09:43:19.257: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) Unhandled websocket event: 24

06-06 09:43:19.267: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) onConnectionError, state: 0 ...

06-06 09:43:19.267: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) onConnectionClosed, state: 2 ...

06-06 09:43:19.267: D/WebSocket.cpp(26288): onConnectionClosed, WebSocket (0xae824ed0) is closing by server.

06-06 09:43:19.267: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) onConnectionClosed DONE!

06-06 09:43:19.267: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) Unhandled websocket event: 45

06-06 09:43:19.267: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) Unhandled websocket event: 33

06-06 09:43:19.267: D/WebSocket.cpp(26288): WebSocket (0xae824ed0) onConnectionClosed, state: 3 ...

06-06 09:43:19.282: D/cocos2d-x debug info(26288): _onError [object Object] object

06-06 09:43:19.282: D/cocos2d-x debug info(26288): [object Object]

06-06 09:43:19.282: D/cocos2d-x debug info(26288): {"type":"error"}

06-06 09:43:19.287: D/WebSocket.cpp(26288): In the destructor of WebSocket (0xae824ed0)

06-06 09:43:19.287: D/WebSocket.cpp(26288): before join ws thread

06-06 09:43:19.292: D/WebSocket.cpp(26288): NOTICE: lws_context_destroy

06-06 09:43:19.292: D/WebSocket.cpp(26288): WebSocket thread exit, helper instance: 0x97987760

06-06 09:43:19.292: D/WebSocket.cpp(26288): after join ws thread

06-06 09:43:19.317: D/cocos2d-x debug info(26288): C connectionError [object Object] string

06-06 09:43:19.317: D/cocos2d-x debug info(26288): error: string

06-06 09:43:19.317: D/cocos2d-x debug info(26288): [object Object]

06-06 09:43:19.317: D/cocos2d-x debug info(26288): connectionError

06-06 09:43:19.317: D/cocos2d-x debug info(26288): C

i tried to log content of error , but it is only "{"type":"error"}" .

Code is so simple . I only start a deepstream server and try to login to server on android client (js cocos2d-js)

like this :

this.client = deepstream(CCDefine.DeepStreamServer).login({username: arg.username, password: arg.password},function(success,data){


cc.log(success,data)

        if(success){
            cc.log('Deep stream connect success')

        }else{
            cc.log('Deep stream connect false')
        }
    })

I find out that cocos use libwebsockets without libuv while deepstream use that . can it problem ? I tried to compile libwebsockets with libuv for android but i failed.

Now i currently resolve this problem by use deepstream java SDK , and make a bridge from java to js. Thank u all.

1 Answers1

0

It's hard to tell what the issue is here, but it looks like the WebSocket API could be incompatible. Could you try logging the contents of the error object in the deepstream error handler? If you could post a small code sample that would be great too.