creator1.4.2升级 到 1.5.1websocket 不能正常连接,为什么和端口会有关系?

今天把项目重1.4.2升级到1.5.1,在mac 机上测试 websocket 在原生环境和模拟器环境下不能正常连接。在web环境下表现正常。
错误如下:

2017-06-27T11:04:40.017Z - normal: Simulator: Cocos2d-JS v3.14
2017-06-27T11:04:40.346Z - normal: Simulator: iShow!
2017-06-27T11:04:40.544Z - normal: Simulator: D/WebSocket.cpp (415): WebSocket thread start, helper instance: 0x7f9f8f14d100
2017-06-27T11:04:40.545Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: Initial logging level 911
2017-06-27T11:04:40.545Z - normal: Simulator:
2017-06-27T11:04:40.545Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: Libwebsockets version: 2.1.0 james@James-Chen.local-v3.4-139-gbdcf7f8
2017-06-27T11:04:40.546Z - normal: Simulator:
2017-06-27T11:04:40.547Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: IPV6 compiled in and enabled
2017-06-27T11:04:40.547Z - normal: Simulator:
2017-06-27T11:04:40.548Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: libev support not compiled in
2017-06-27T11:04:40.548Z - normal: Simulator:
2017-06-27T11:04:40.548Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: libuv support not compiled in
2017-06-27T11:04:40.549Z - normal: Simulator:
2017-06-27T11:04:40.549Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: Threads: 1 each 1024 fds
2017-06-27T11:04:40.549Z - normal: Simulator:
2017-06-27T11:04:40.550Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: mem: platform fd map: 8192 bytes
2017-06-27T11:04:40.550Z - normal: Simulator:
2017-06-27T11:04:40.550Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: Compiled with OpenSSL support
2017-06-27T11:04:40.551Z - normal: Simulator:
2017-06-27T11:04:40.551Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: mem: per-conn: 512 bytes + protocol rx buf
2017-06-27T11:04:40.551Z - normal: Simulator:
2017-06-27T11:04:40.551Z - normal: Simulator: D/WebSocket.cpp (873): scheme: ws, host: 192.168.1.8, port: 88, path: /wf
2017-06-27T11:04:40.552Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: Creating Vhost ‘default’ port -1, 1 protocols, IPv6 on
2017-06-27T11:04:40.552Z - normal: Simulator:
2017-06-27T11:04:40.552Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: lws_protocol_init
2017-06-27T11:04:40.553Z - normal: Simulator:
2017-06-27T11:04:40.553Z - normal: Simulator: D/WebSocket.cpp (1322): WebSocket (0x7f9f8f14ced0) Unhandled websocket event: 32
2017-06-27T11:04:40.553Z - normal: Simulator: D/WebSocket.cpp (1322): WebSocket (0x7f9f8f14ced0) Unhandled websocket event: 29
2017-06-27T11:04:40.553Z - normal: Simulator: D/WebSocket.cpp (1322): WebSocket (0x7f9f8f14ced0) Unhandled websocket event: 24
2017-06-27T11:04:40.554Z - normal: Simulator: D/WebSocket.cpp (1197): WebSocket (0x7f9f8f14ced0) onConnectionError, state: 0 …
2017-06-27T11:04:40.554Z - normal: Simulator: D/WebSocket.cpp (1226): WebSocket (0x7f9f8f14ced0) onConnectionClosed, state: 2 …
2017-06-27T11:04:40.554Z - normal: Simulator: D/WebSocket.cpp (1256): onConnectionClosed, WebSocket (0x7f9f8f14ced0) is closing by server.
2017-06-27T11:04:40.555Z - normal: Simulator: D/WebSocket.cpp (1279): WebSocket (0x7f9f8f14ced0) onConnectionClosed DONE!
2017-06-27T11:04:40.555Z - normal: Simulator: D/WebSocket.cpp (1322): WebSocket (0x7f9f8f14ced0) Unhandled websocket event: 45
2017-06-27T11:04:40.555Z - normal: Simulator: D/WebSocket.cpp (1322): WebSocket (0x7f9f8f14ced0) Unhandled websocket event: 33
2017-06-27T11:04:40.555Z - normal: Simulator: D/WebSocket.cpp (1226): WebSocket (0x7f9f8f14ced0) onConnectionClosed, state: 3 …
2017-06-27T11:04:40.556Z - normal: Simulator: WebSocket instance wasn’t ready…
2017-06-27T11:04:40.556Z - normal: Simulator: Send Text fired an error
2017-06-27T11:04:40.556Z - normal: Simulator: WebSocket instance closed.
2017-06-27T11:04:44.032Z - normal: Simulator: D/WebSocket.cpp (545): In the destructor of WebSocket (0x7f9f8f14ced0)
2017-06-27T11:04:44.032Z - normal: Simulator: D/WebSocket.cpp (565): before join ws thread
2017-06-27T11:04:44.033Z - normal: Simulator: D/WebSocket.cpp (167): NOTICE: lws_context_destroy
2017-06-27T11:04:44.033Z - normal: Simulator:
2017-06-27T11:04:44.033Z - normal: Simulator: D/WebSocket.cpp (425): WebSocket thread exit, helper instance: 0x7f9f8f14d100
2017-06-27T11:04:44.034Z - normal: Simulator: D/WebSocket.cpp (567): after join ws thread
2017-06-27T11:04:44.034Z - normal: Simulator: jsbindings: finalizing JS object 0x1b037340 (WebSocket)
2017-06-27T11:04:44.044Z - normal: Simulator: basic_object_finalize 0x1a242af0 …
2017-06-27T11:04:44.045Z - normal: Simulator: jsbindings: finalizing JS object 0x1a242b20 (WebSocket)
2017-06-27T11:04:44.045Z - normal: Simulator: jsbindings: finalizing JS object 0x1a242b50 (SocketIO)
2017-06-27T11:04:44.045Z - normal: Simulator: basic_object_finalize 0x1a242be0 …
2017-06-27T11:04:44.046Z - normal: Simulator: basic_object_finalize 0x1a242e80 …

测试代码如下:

var ws = new WebSocket(“ws://192.168.1.8:88/wf”);
ws.onopen = function (event) {
console.log(“Send Text WS was opened.”);
};
ws.onmessage = function (event) {
console.log("response text msg: " + event.data);
};
ws.onerror = function (event) {
console.log(“Send Text fired an error”);
};
ws.onclose = function (event) {
console.log(“WebSocket instance closed.”);
};


进一步测试发现:端口用80的话 web环境和原生环境都可以正常,用别的端口的话 web环境正常。而在1.4.2环境下 用别的端口也正常。

求助大神们这事为啥呀?

能把你服务器部署到外网,我们这里连接查一下么?

???

遇到同样的问题,不知道怎么解决的?