LeanCloudChatKit是从github上下载,没有进行任何改动,用的sdk版本是8.2.9,在app切换后台3五分钟PushService#onDestroy后,再切换到前台发送消息提示java.lang.RuntimeException: Connection Lost,在小米跟oppo手机上必现,以下为异常日志。
2022-08-01 14:08:13.997 18360-19114/cn.leancloud.imkitapplication D/StandardWebSocketClient: onWebsocketPong()
2022-08-01 14:08:29.708 18360-18360/cn.leancloud.imkitapplication I/PushService: PushService#onDestroy
2022-08-01 14:08:29.710 18360-18360/cn.leancloud.imkitapplication D/StandardWebSocketClient: onClose socket=cn.leancloud.websocket.StandardWebSocketClient@a589b, code=1006, message=Connectivity broken
2022-08-01 14:08:29.710 18360-18360/cn.leancloud.imkitapplication D/LCConnectionManager: client(cn.leancloud.websocket.StandardWebSocketClient@a589b) closed...
2022-08-01 14:08:29.711 18360-18360/cn.leancloud.imkitapplication D/Event: No subscribers registered for event class cn.leancloud.chatkit.event.LCIMConnectionChangeEvent
2022-08-01 14:08:29.711 18360-18360/cn.leancloud.imkitapplication D/Event: No subscribers registered for event class de.greenrobot.event.NoSubscriberEvent
2022-08-01 14:08:47.960 18360-18360/cn.leancloud.imkitapplication D/PushService: PushService#onCreate
2022-08-01 14:08:47.960 18360-19168/cn.leancloud.imkitapplication D/LCConnectionManager: start connection with callback...
2022-08-01 14:08:47.961 18360-19168/cn.leancloud.imkitapplication D/AppRouter: fetchRTMServerFromRemote. router=https://dyrq8yfh.lc-cn-n1-shared.com, appId=dYRQ8YfHRiILshUnfFJu2eQM-gzGzoHsz, installationId=583383838d8b0a4c3ccb60a920739184
2022-08-01 14:08:47.964 18360-18360/cn.leancloud.imkitapplication I/PushService: PushService#onStartCommand
2022-08-01 14:08:47.965 18360-18360/cn.leancloud.imkitapplication D/PushService: networking is fine and try to start connection to leancloud.
2022-08-01 14:08:47.965 18360-18360/cn.leancloud.imkitapplication D/LCConnectionManager: on starting connection, save callback...
2022-08-01 14:08:47.974 18360-18360/cn.leancloud.imkitapplication D/PushService: Connection resumed with Wifi...
2022-08-01 14:08:47.975 18360-18360/cn.leancloud.imkitapplication D/LCConnectionManager: on starting connection, save callback...
2022-08-01 14:08:48.289 18360-19108/cn.leancloud.imkitapplication D/LoggingInterceptor: Request: curl -X GET
https://dyrq8yfh.lc-cn-n1-shared.com/v1/route?appId=dYRQ8YfHRiILshUnfFJu2eQM-gzGzoHsz&installationId=583383838d8b0a4c3ccb60a920739184&secure=1
2022-08-01 14:08:48.296 18360-19108/cn.leancloud.imkitapplication D/LoggingInterceptor: Response: 200
server: openresty
date: Mon, 01 Aug 2022 06:08:48 GMT
content-type: application/json
content-length: 173
vary: Accept-Encoding
strict-transport-security: max-age=31536000
{"groupId":"g0","groupUrl":"https:\/\/router-g0-push.leancloud.cn","server":"wss:\/\/cn-n1-cell2.leancloud.cn\/","secondary":"wss:\/\/cn-n1-cell1.leancloud.cn\/","ttl":1800}
2022-08-01 14:08:48.305 18360-18360/cn.leancloud.imkitapplication D/LCConnectionManager: try to connect server: wss://cn-n1-cell1.leancloud.cn/
2022-08-01 14:08:48.652 18360-19174/cn.leancloud.imkitapplication D/StandardWebSocketClient: onOpen socket=cn.leancloud.websocket.StandardWebSocketClient@f12b550, status=101, statusMsg=Switching Protocols
2022-08-01 14:08:48.653 18360-19174/cn.leancloud.imkitapplication D/LCConnectionManager: webSocket(client=cn.leancloud.websocket.StandardWebSocketClient@f12b550) established...
2022-08-01 14:08:48.654 18360-19174/cn.leancloud.imkitapplication D/LCDefaultConnectionListener: web socket opened, send session open.
2022-08-01 14:08:48.655 18360-18360/cn.leancloud.imkitapplication D/PushService: processIMRequests...
2022-08-01 14:08:48.655 18360-18360/cn.leancloud.imkitapplication D/PushService: processIMRequestsFromClient...
2022-08-01 14:08:48.664 18360-19174/cn.leancloud.imkitapplication D/StandardWebSocketClient: client(cn.leancloud.websocket.StandardWebSocketClient@f12b550) uplink : cmd: session
op: open
appId: "dYRQ8YfHRiILshUnfFJu2eQM-gzGzoHsz"
peerId: "Tom"
sessionMessage {
ua: "LeanCloud-Java-SDK/8.2.9"
r: true
deviceId: "583383838d8b0a4c3ccb60a920739184"
st: "RiILshUnfFJu2eQM-gzGzoHszcLEQkDY7RqOQd1alF2JzPg"
lastPatchTime: 1659333488552
configBitmap: 175
}
2022-08-01 14:08:48.670 18360-18360/cn.leancloud.imkitapplication E/LCChatKit: cn.leancloud.chatkit.activity.LCIMConversationFragment$10 done():597
cn.leancloud.im.v2.LCIMException: java.lang.RuntimeException: Connection Lost
at cn.leancloud.im.AndroidOperationTube$10.execute(AndroidOperationTube.java:238)
at cn.leancloud.im.LCIMBaseBroadcastReceiver.onReceive(LCIMBaseBroadcastReceiver.java:35)
at cn.leancloud.utils.LocalBroadcastManager.executePendingBroadcasts(LocalBroadcastManager.java:311)
at cn.leancloud.utils.LocalBroadcastManager$1.handleMessage(LocalBroadcastManager.java:107)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
Caused by: java.lang.RuntimeException: Connection Lost
at cn.leancloud.session.LCConversationHolder.checkSessionStatus(LCConversationHolder.java:442)
at cn.leancloud.session.LCConversationHolder.sendMessage(LCConversationHolder.java:292)
at cn.leancloud.im.DirectlyOperationTube.sendMessageDirectly(DirectlyOperationTube.java:295)
at cn.leancloud.push.PushService.processIMRequestsFromClient(PushService.java:718)
at cn.leancloud.push.PushService.processIMRequests(PushService.java:603)
at cn.leancloud.push.PushService.access$400(PushService.java:62)
at cn.leancloud.push.PushService$4.internalDone0(PushService.java:206)
at cn.leancloud.push.PushService$4.internalDone0(PushService.java:202)
at cn.leancloud.callback.LCCallback$1.run(LCCallback.java:28)
at android.os.Handler.handleCallback(Handler.java:873)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:201)
at android.app.ActivityThread.main(ActivityThread.java:6810)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:873)
2022-08-01 14:08:48.725 18360-19174/cn.leancloud.imkitapplication D/LCConnectionManager: client(cn.leancloud.websocket.StandardWebSocketClient@f12b550) downlink: cmd: session
op: opened
appId: "dYRQ8YfHRiILshUnfFJu2eQM-gzGzoHsz"
peerId: "Tom"
service: 2
serverTs: 1659334128574
sessionMessage {
st: "RiILshUnfFJu2eQM-gzGzoHszcLEQkDY7RqOQd1alF2JzPg"
stTtl: 16640
}
2022-08-01 14:08:48.725 18360-19174/cn.leancloud.imkitapplication D/LCDefaultConnectionListener: new message arriving. peerId=Tom, requestId=null, command=0
2022-08-01 14:08:48.725 18360-19174/cn.leancloud.imkitapplication D/LCDefaultConnectionListener: processSessionCommand. op=opened,requestKey=null
2022-08-01 14:08:48.726 18360-19174/cn.leancloud.imkitapplication D/DefaultSessionListener: internal session open.
2022-08-01 14:08:48.727 18360-18360/cn.leancloud.imkitapplication D/Event: No subscribers registered for event class cn.leancloud.chatkit.event.LCIMConnectionChangeEvent
2022-08-01 14:08:48.727 18360-18360/cn.leancloud.imkitapplication D/Event: No subscribers registered for event class de.greenrobot.event.NoSubscriberEvent
感觉是后台久了切换到前台没有进行重连,控制台上看到的状态也是离线,麻烦定位下原因,挺急的。