Tencent / mars

Mars is a cross-platform network component developed by WeChat.
Other
17.34k stars 3.63k forks source link

监控到网络切换,调用OnNetworkChange()无效 #409

Closed HalfAnApple closed 6 years ago

HalfAnApple commented 6 years ago

https://github.com/Tencent/mars/blob/1db39d513c108fddb53a272f321fa58713ce5dc4/samples/iOS/iOSDemo/Bussiness/NetworkService.mm#L178-L184 使用samples/iOSDemo里的处理,由WiFi切换到4G网络,网络状态改变回调调用了OnNetworkChange(),但在此之后发送cgi没回应,几分钟后日志提示 task socket close,改变网络前cgi req是ok的,这里应该怎么处理?重建mars么?

以下Mars日志

//切换网络
2018-05-30 14:19:46.671219+0800 Asset[54977:23790486] Reachability Flag Status: -R ------d localWiFiStatusForFlags
//调用OnNetworkChange
2018-05-30 14:19:46.965334+0800 Asset[54977:23790666] [I][mars::stn][net_core.cc, OnNetworkChange, 390][-> OnNetworkChange
2018-05-30 14:19:46.966261+0800 Asset[54977:23790486] Reachability Flag Status: WR t------ networkStatusForFlags
2018-05-30 14:19:46.966615+0800 Asset[54977:23790486] Reachability Flag Status: WR t------ networkStatusForFlags
2018-05-30 14:19:46.972759+0800 Asset[54977:23790486] Reachability Flag Status: -R ------- networkStatusForFlags
2018-05-30 14:19:46.974744+0800 Asset[54977:23790486] Reachability Flag Status: -R ------- networkStatusForFlags
2018-05-30 14:19:46.975224+0800 Asset[54977:23790486] Reachability Flag Status: WR t------ networkStatusForFlags
2018-05-30 14:19:46.975282+0800 Asset[54977:23790486] Reachability Flag Status: WR t------ networkStatusForFlags
2018-05-30 14:19:46.979833+0800 Asset[54977:23790652] TIC Read Status [2:0x0]: 1:57
2018-05-30 14:19:46.979870+0800 Asset[54977:23790652] TIC Read Status [2:0x0]: 1:57
2018-05-30 14:19:47.021750+0800 Asset[54977:23790486] Reachability Flag Status: WR t------ networkStatusForFlags
2018-05-30 14:19:47.021854+0800 Asset[54977:23790486] Reachability Flag Status: WR t------ networkStatusForFlags

//发起一个CGi请求
2018-05-30 14:19:53.158601+0800 Asset[54977:23790486] [D][][ServiceCenter.mm, getService, 99][Debug:Create service object: <ASMatchService: 0x1c6267c00>
2018-05-30 14:19:53.478359+0800 Asset[54977:23790663] 54977: CFNetwork internal error (0xc01a:/BuildRoot/Library/Caches/com.apple.xbs/Sources/CFNetwork/CFNetwork-889.9/Loading/URLConnectionLoader.cpp:315)

2018-05-30 14:21:49.370837+0800 Asset[54977:23791387] TIC Read Status [8:0x0]: 1:57
2018-05-30 14:21:49.370882+0800 Asset[54977:23791387] TIC Read Status [8:0x0]: 1:57

2018-05-30 14:24:08.015617+0800 Asset[54977:23790665] [I][mars::comm][alarm.cc, OnAlarm, 131][OnAlarm id:6108801400, seq:7, elapsed:270001, after:270000, miss:1, android alarm:false, runing
2018-05-30 14:24:08.016029+0800 Asset[54977:23790670] [I][mars::comm][alarm.cc, Start, 67][alarm id:6108801240, after:5000, seq:8, po.reg.q:6107656192,po.reg.s:0,po.s:65
2018-05-30 14:24:08.016099+0800 Asset[54977:23790670] [I][mars::comm][alarm.cc, Start, 67][alarm id:6108801400, after:270000, seq:9, po.reg.q:6107656192,po.reg.s:0,po.s:66
2018-05-30 14:24:08.016199+0800 Asset[54977:23790670] [I][mars::stn][longlink.cc, __RunReadWrite, 563][start noop taskid:4294967295, cmdid:6,  last:(270000,270001), next:270000
2018-05-30 14:24:08.016334+0800 Asset[54977:23790670] [I][mars::comm][alarm.cc, Cancel, 90][alarm cancel id:6108801400, seq:9, after:270000
2018-05-30 14:24:08.016400+0800 Asset[54977:23790670] [I][mars::comm][alarm.cc, Start, 67][alarm id:6108801400, after:270000, seq:10, po.reg.q:6107656192,po.reg.s:0,po.s:67
2018-05-30 14:24:08.016497+0800 Asset[54977:23790670] [D][][stn_callback.mm, TrafficData, 48][send:20, recv:0
2018-05-30 14:24:08.016543+0800 Asset[54977:23790670] [I][mars::stn][longlink.cc, __RunReadWrite, 641][task socket send sock:39, all send:20, count:1, sub send taskid:4294967295, cmdid:0, , len(S:20, 20/20),
2018-05-30 14:24:13.019204+0800 Asset[54977:23790665] [I][mars::comm][alarm.cc, OnAlarm, 131][OnAlarm id:6108801240, seq:8, elapsed:5004, after:5000, miss:4, android alarm:false, runing
2018-05-30 14:24:13.019558+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getNetInfo, 143][-> getNetInfo
2018-05-30 14:24:13.019632+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getNetInfo, 143][<- getNetInfo +0,
2018-05-30 14:24:13.019696+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getCurSIMInfo, 317][isp_code:46002
2018-05-30 14:24:13.019939+0800 Asset[54977:23790670] [E][mars::stn][longlink.cc, __RunReadWrite, 555][task socket close sock:39, noop timeout, nread:0, nwrite:20, net_type:46002, info nwrite:20 taskid:4294967295, cmdid:0, cgi: ; task socket close getsocktcpinfo:tcpi_state=0x4, tcpi_snd_wscale=0x7, tcpi_rcv_wscale=0x6, tcpi_options=0x7, tcpi_flags=0x1, tcpi_rto=0x848, tcpi_maxseg=0x5A8, tcpi_snd_ssthresh=0x3FFFC000, tcpi_snd_cwnd=0x111C, tcpi_snd_wnd=0x7180, tcpi_snd_sbbytes=0x14, tcpi_rcv_wnd=0x201E0, tcpi_rttcur=0xA, tcpi_srtt=0x0, tcpi_rttvar=0x5, tcpi_txpackets=0x4, tcpi_txbytes=0xAA, tcpi_txretransmitbytes=0x0, tcpi_rxpackets=0x4, tcpi_rxbytes=0x10A, tcpi_rxoutoforderbytes=0x
2018-05-30 14:24:13.020183+0800 Asset[54977:23790670] [I][mars::comm][alarm.cc, Cancel, 90][alarm cancel id:6108801400, seq:10, after:270000
2018-05-30 14:24:13.020309+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getNetInfo, 143][-> getNetInfo
2018-05-30 14:24:13.020341+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getNetInfo, 143][<- getNetInfo +0,
2018-05-30 14:24:13.020428+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getSignal, 164][-> getSignal
2018-05-30 14:24:13.020465+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getSignal, 164][<- getSignal +0,
2018-05-30 14:24:13.020497+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getNetInfo, 143][-> getNetInfo
2018-05-30 14:24:13.020523+0800 Asset[54977:23790670] [V][mars::comm][platform_comm.mm, getNetInfo, 143][<- getNetInfo +0,
2018-05-30 14:24:13.020551+0800 Asset[54977:23790670] [I][mars::stn][longlink.cc, __ConnectStatus, 341][connect status from:2 to:3, nettype:2
2018-05-30 14:24:13.020636+0800 Asset[54977:23790670] [I][mars::stn][longlink.cc, __Run, 370][<- __Run +280958,

2018-05-30 14:29:46.961083+0800 Asset[54977:23790647] [I][mars::comm][message_queue.cc, __ANRCheckCallback, 682][anr check content:110, handler:(6108229632,5)
2018-05-30 14:29:51.966418+0800 Asset[54977:23797211] [F][mars::comm][message_queue.cc, Run, 805][[ASSERT(anr dead lock)]timeout:600000, tid:7518719424, runing time:605009, real time:605009, used_cpu_time:593957, iOS_style:0
garryyan commented 6 years ago

看日志,调用 OnNetworkChange, 390][-> OnNetworkChange 函数之后,没有出来,应该卡在什么位置了。关联源码调试下 看卡死在什么地方了