Browse Source

保存日志优化

newdev_shunjiawei
liwei1dao 5 months ago
parent
commit
5ad87ddc30
  1. 16
      local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/StsAgent.kt

16
local_plugins/agent_service/android/src/main/kotlin/com/yunqiinnovation/agent_service/StsAgent.kt

@ -638,12 +638,14 @@ class StsAgent(
"?deviceNo=${config.deviceNo}&deviceId=${config.deviceId}" +
"&productId=${config.productId}&productKey=${config.productKey}" +
"&sign=$sign&sn=$sn&ts=$ts"
Log.i(TAG, "[YIDONG] connectWs: 连接WSS deviceNo=${config.deviceNo} deviceId=${config.deviceId} sn=$sn")
Log.i(TAG, "[YIDONG] connectWs: 连接WSS deviceNo=${config.deviceNo} deviceId=${config.deviceId} sn=$sn ts=$ts sign=$sign")
Log.i(TAG, "[YIDONG] connectWs: 完整URL = $url")
val req = Request.Builder().url(url)
.header("Origin", "https://ivs.chinamobiledevice.com:11443")
.header("Host", "ivs.chinamobiledevice.com:11443")
.build()
Log.i(TAG, "[YIDONG] connectWs: 请求头 Origin=https://ivs.chinamobiledevice.com:11443 Host=ivs.chinamobiledevice.com:11443")
var resolved = false
@ -667,7 +669,17 @@ class StsAgent(
override fun onMessage(ws: WebSocket, bytes: okio.ByteString) {}
override fun onFailure(ws: WebSocket, t: Throwable, response: Response?) {
Log.e(TAG, "[YIDONG] connectWs: WSS连接失败 ${t.message}")
val respInfo = if (response != null) {
val bodySnippet = try {
response.peekBody(2048).string()
} catch (e: Exception) { "<body read failed: ${e.message}>" }
"code=${response.code} message=${response.message} headers=${response.headers} body=$bodySnippet"
} else {
"<no response>"
}
Log.e(TAG, "[YIDONG] connectWs: WSS连接失败 exception=${t.javaClass.name} message=${t.message}")
Log.e(TAG, "[YIDONG] connectWs: WSS连接失败 response: $respInfo")
Log.e(TAG, "[YIDONG] connectWs: WSS连接失败 url=$url")
if (webSocket === ws) webSocket = null // 只清除自己的引用,避免覆盖新 WS
if (!resolved) { resolved = true; cont.resumeWithException(t) }
else launch { handleWsDone() }

Loading…
Cancel
Save