Iphone7s websocket的问题

如下图的log,[NativeSdk] Net is change: 0 这个是使用oc写的原生的检测网络状态,当我开启飞行模式的时候,会触发这个网络回调,此时网络已经断开了,但是websocket此时并没有触发onError,onClose事件,然后我在游戏中有其他网络操作,等了很久才收到onClose事件,因为游戏的断线重连逻辑是放在onError, onClose里面的,所以这块的逻辑出现了问题,直接表现就是网络断开不能触发onClose事件,这个问题在其他苹果手机上没有出现,我这年目前只发现在iphone7s上有,目前我的处理办法就是oc处理这块问题,希望官方能够排查下,辛苦了,安卓手机没有此问题,只发生在iPhone7s上

[Socket 发送数据==>]{"id":1030,"netId":4,"wsKey":"wsKey101","msg":"send_BeganGame","data":{"vc":0,"room":"11"}}
Safely done, msg(5)!
msg(5) append: 0 + 24 = 24
msg(5) was totally sent!
-----------------------------------------------------------
Receiving data:index:5, len=15
Notify data len 15 to Cocos thread.
[Socket 接收数据<==]{"id":2030,"wsKey":"wsKey101","msg":"recv_BeganGame","code":0,"data":{"room":11}}
Receiving data:index:6, len=128
Notify data len 128 to Cocos thread.
[Socket 接收数据<==]{"id":2031,"wsKey":"wsKey101","msg":"recv_DeskEnterUser","code":0,"data":{"u2":{"name":"%E9%83%91%E9%AB%98%E6%A0%BC","up":130000,"ct":0,"wn":0,"wr":0,"cw":0,"img":1001,"head":"","isr":1},"room":11}}
V/AudioPlayer (69): ~AudioPlayer() (0x111077ee0), id=6
V/AudioPlayer (83): AudioPlayer::destroy begin, id=6
V/AudioPlayer (128): Before alSourceStop
V/AudioPlayer (130): Before alSourcei
V/AudioPlayer (136): AudioPlayer::destroy end, id=6
Safely done, msg(6)!
msg(6) append: 0 + 6 = 6
msg(6) was totally sent!
-----------------------------------------------------------
>>>>>>>>>>>>>>>win hide<<<<<<<<<<<<<<<<<
>>>>>>>>>>>>>>>win show<<<<<<<<<<<<<<<<<
消息列表中不存在: GameLocalMsg_Game_OnWinShow
2017-05-02 15:47:52.485272+0800 uupoker-mobile[296:15026] Reachability Flag Status: -- ------- networkStatusForFlags
2017-05-02 15:47:52.485823+0800 uupoker-mobile[296:15026] ------【ios】网络状态发生改变----------
[NativeSdk] Net is change: 0
Safely done, msg(7)!
msg(7) append: 0 + 6 = 6
msg(7) was totally sent!
-----------------------------------------------------------
cocos2d: QuadCommand: resizing index size from [-1] to [2560]
Safely done, msg(8)!
msg(8) append: 0 + 6 = 6
msg(8) was totally sent!
-----------------------------------------------------------
Safely done, msg(9)!
msg(9) append: 0 + 6 = 6
msg(9) was totally sent!
-----------------------------------------------------------
Safely done, msg(10)!
msg(10) append: 0 + 6 = 6
msg(10) was totally sent!
-----------------------------------------------------------
V/AudioPlayer (147): AudioPlayer::play2d, _alSource: 2401
[Socket 发送数据==>]{"id":1037,"netId":10,"wsKey":"wsKey101","msg":"send_ChangeDesk","data":{"room":11}}
Safely done, msg(11)!
msg(11) append: 0 + 15 = 15
msg(11) was totally sent!
-----------------------------------------------------------
V/AudioPlayer (69): ~AudioPlayer() (0x111077ee0), id=7
V/AudioPlayer (83): AudioPlayer::destroy begin, id=7
V/AudioPlayer (128): Before alSourceStop
V/AudioPlayer (130): Before alSourcei
V/AudioPlayer (136): AudioPlayer::destroy end, id=7
Safely done, msg(12)!
msg(12) append: 0 + 6 = 6
msg(12) was totally sent!
-----------------------------------------------------------
Safely done, msg(13)!
msg(13) append: 0 + 6 = 6
msg(13) was totally sent!
-----------------------------------------------------------
Safely done, msg(14)!
msg(14) append: 0 + 6 = 6
msg(14) was totally sent!
-----------------------------------------------------------
Safely done, msg(15)!
msg(15) append: 0 + 6 = 6
msg(15) was totally sent!
-----------------------------------------------------------
Safely done, msg(16)!
msg(16) append: 0 + 6 = 6
msg(16) was totally sent!
-----------------------------------------------------------
Safely done, msg(17)!
msg(17) append: 0 + 6 = 6
msg(17) was totally sent!
-----------------------------------------------------------
Safely done, msg(18)!
msg(18) append: 0 + 6 = 6
msg(18) was totally sent!
-----------------------------------------------------------
Safely done, msg(19)!
msg(19) append: 0 + 6 = 6
msg(19) was totally sent!
-----------------------------------------------------------
Safely done, msg(20)!
msg(20) append: 0 + 6 = 6
msg(20) was totally sent!
-----------------------------------------------------------
Safely done, msg(21)!
msg(21) append: 0 + 6 = 6
msg(21) was totally sent!
-----------------------------------------------------------
Safely done, msg(22)!
msg(22) append: 0 + 6 = 6
msg(22) was totally sent!
-----------------------------------------------------------
WARN: error on reading from skt

WebSocket (0x1701d1580) onConnectionClosed ...
NOTICE: lws_context_destroy

onConnectionClosed: WebSocket (0x1701d1580) was closed, no need to close it again!
WebSocket thread exit, helper instance: 0x1700b0320
[NetSocketMgr] clean beat: success to clean id = 0
[NetSocketMgr] Socket Close
In the destructor of WebSocket (0x1701d1580)
[NetSocketMgr] clean beat: failed, no heart to stop
[WebSocket::init] _host: wddz.haoxiaow.com, _port: 9500, _path: /?time=1493711345&version=1.0&platform=4&randstr=xYkCd2j6&sign=579e53bf0e74eda90fac09d75b34b3b7
WebSocket thread start, helper instance: 0x1740bd8e0
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 7168 fds

NOTICE:  mem: platform fd map: 57344 bytes

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

2017-05-02 15:49:04.862716+0800 uupoker-mobile[296:15850] dnssd_clientstub write_all(12) DEFUNCT
2017-05-02 15:49:04.862737+0800 uupoker-mobile[296:15850] dnssd_clientstub deliver_request ERROR: write_all(12, 58 bytes) failed
2017-05-02 15:49:04.862757+0800 uupoker-mobile[296:15850] dnssd_clientstub write_all(12) DEFUNCT
ERR: getaddrinfo: nodename nor servname provided, or not known

WebSocket (0x1741d0d10) onConnectionError ...
Ready state is closing or was closed, code=2, quit websocket thread!
NOTICE: lws_context_destroy

WebSocket (0x1741d0d10) onConnectionClosed ...
WebSocket thread exit, helper instance: 0x1740bd8e0
[Socket Error]
[NetSocketMgr] clean beat: failed, no heart to stop
消息列表中不存在: GameMsg_SOCKET_ERROR
<no filename="filename">:0:null is not a function

In the destructor of WebSocket (0x1741d0d10)

iphone7s啥时候发布的

iphone7s ??

说错了,是IPhone 7 Plus

####好像断网(如飞行模式、网络不好等),websocket是没有办法立刻知道的,建议你在oc那检查到网络断开的时候主动断开websocket,oc那检查网来了在主动链接websocket

2赞

用的creator1.4.2,也有这个问题,发现7plus和ipad mini,断网都不能马上触发onclose,要等好久(起码5分钟),android上没这问题