模拟器运行没问题打包闪退, 大概在HttpClientHttpResponseEPc

好像是http请求出问题,这种应该怎么调试
日志是:

02-20 15:37:22.149 22284 22284 F DEBUG   : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0
02-20 15:37:22.149 22284 22284 F DEBUG   :     r0 da1d4de8  r1 00000000  r2 00000110  r3 00000001
02-20 15:37:22.149 22284 22284 F DEBUG   :     r4 d9e2a000  r5 00000000  r6 00000000  r7 e215cf50
02-20 15:37:22.149 22284 22284 F DEBUG   :     r8 d8dcc868  r9 00000000  sl d8dcc884  fp d8dcc874
02-20 15:37:22.149 22284 22284 F DEBUG   :     ip e2127afc  sp d8dcc7a8  lr e1c3e658  pc f6d73976  cpsr 600b0030
02-20 15:37:22.159  3107  3756 V audio_hw_primary: start_output_stream+, out->device : 00000002 , out->type = 1
02-20 15:37:22.159 22284 22284 F DEBUG   :
02-20 15:37:22.159 22284 22284 F DEBUG   : backtrace:
02-20 15:37:22.159 22284 22284 F DEBUG   :     #00 pc 00018976  /system/lib/libc.so (strcpy+1)
02-20 15:37:22.159 22284 22284 F DEBUG   :     #01 pc 00ace654  /data/app/com.xxx.aaal-1/lib/arm/libcocos2djs.so (_ZN7cocos2d7network10HttpClient15processResponseEPNS0_12HttpResponseEPc+1244)
02-20 15:37:22.159 22284 22284 F DEBUG   :     #02 pc 00acf46c  /data/app/com.com.xxx.aaal-1/lib/arm/libcocos2djs.so (_ZN7cocos2d7network10HttpClient13networkThreadEv+664)

这个没人管吗… 没人遇到过?

该如何重现这个问题?有没有 demo ?

我们就是用了socketio连接服务器, demo是说apk吗?还是要源码?源码的话我可能需要尽量精简一下再给你们了

工程本身最好,因为不知道你是怎么遇到这个问题的,另外,也麻烦提供出问题的设备和环境

我们在ios真机也遇到问题了… 现在native模式就没成功过…先给你发ios日志吧,这个清楚点…

以下是iPhone7真机运行出的问题,连接后发消息报"Client not yet connected"

[WebSocket::init] _host: xxx.com _port: 80, _path: /socket.io/1/websocket/
V/AudioCache (144): readDataTask, cache id=1
WebSocket thread start, helper instance: 0x1700bc0e0
NOTICE: Initial logging level 967

NOTICE: Libwebsockets version: 1.7.8 linwenhai@LindeMacBook-Pro.local-v3.4-49-g9369eea

NOTICE: IPV6 compiled in and enabled

NOTICE: libev support not compiled in

NOTICE: Threads: 1 each 256 fds

NOTICE: mem: platform fd map: 2048 bytes

NOTICE: mem: per-conn: 368 bytes + protocol rx buf

JSB SocketIO.send method called
JSB SocketIO send mesage: logincmd
JSB SocketIO::SIODelegate->onError method called from native with data: Client not yet connected
JSB SocketIO::SIODelegate->fireEventToScript method called from native with name ‘error’ data: Client not yet connected

直接提示" Client not yet connected".

调用socketio的代码如下:

if (!cc.sys.isNative) {
   io = require('socket.io');
  }
  else{
    io = SocketIO.connect;
  }
  
  var socket = io('http://xxx.com:80');

你真的连 xxx.com 的话肯定连接不上吧,最后报 client not yet connected 不是也很正常么?

这个连接不上我肯定早就说了,相同的代码web版本跑没问题的

域名我只是因为公开发布所以换成了xx.com 真实代码写的的是我们自己的服务器.

那我只好帮你召唤大神了 @dumganhar

testsocket_min.zip (509.1 KB)

我新建了一个项目,构建ios native方式在设备上运行,可以复现这个问题, 貌似和端口号有关系,默认是0:
_port: 0, _path: /socket.io/1/websocket/?

我自己强制写成80的话,服务器那边好像还不支持.

很奇怪,
io = SocketIO.connect;
var socket = io(‘http://mydomain.cn’);
就这么简单的调用,难道没人遇到过?
难道只有我在native模式用过socketio? 还是说我哪里设置不对导致的?

带build目录的可以在这里下载:
https://dn-3as8zhui.qbox.me/6fb7e1c245074a247757.zip

我先看看。~~~~

你用的creator版本是?

我看你的demo,connect后直接去send,但这时可能都还没连接上啊。
建议参考一些SocketIOTest.js

    onMenuSIOClientClicked: function(sender) {

        //create a client by using this static method, url does not need to contain the protocol
        var sioclient = SocketIO.connect("ws://tools.itharbors.com:4000", {"force new connection" : true});

        //if you need to track multiple sockets it is best to store them with tags in your own array for now
        sioclient.tag = "Test Client";

        //attaching the status label to the socketio client
        //this is only necessary in javascript due to scope within shared event handlers,
        //as 'this' will refer to the socketio client
        sioclient.statusLabel = this._sioClientStatus;

        //register event callbacks
        //this is an example of a handler declared inline
        sioclient.on("connect", function() {
            var msg = sioclient.tag + " Connected!";
            this.statusLabel.setString(msg);
            cc.log(msg);
            sioclient.send(msg);
        });

        //example of a handler that is shared between multiple clients
        sioclient.on("message", this.message);

        sioclient.on("echotest", function(data) {
            cc.log("echotest 'on' callback fired!");
            var msg = this.tag + " says 'echotest' with data: " + data;
            this.statusLabel.setString(msg);
            cc.log(msg);
        });

        sioclient.on("testevent", this.testevent);

        sioclient.on("disconnect", this.disconnection);

        this._sioClient = sioclient;

    },

监听connect事件,只有connect事件回调后才可以调用send来发送数据。

你运行了没… 我那个send是临时加上的,可以删除。 你运行看一下日志, 没连接上

错误信息是这样的:
WebSocket (0x1701dd5b0) onConnectionError …
Ready state is closing or was closed, code=2, quit websocket thread!

creator 版本. v1.3.3

正在查。~~~

嗯,默认是0的确是有问题的。
我发现你的服务器,如果加上80端口,macOS上连接一直返回404, 这个能查下原因么?
我测试其他http网站,强制加上80端口,是能够返回200返回码的。

嗯嗯,确实,加80端口不支持这个我研究下, 可是0端口这个不知什么时候可以修复? 按说这个是比较常见的操作方式,不知道别人为什么没遇到这个问题…