個(gè)人博客:【lzan13 / 關(guān)于環(huán)信3.xSDK日志簡(jiǎn)單分析
】
前言
首先說(shuō)下環(huán)信日志保存的機(jī)制,這邊只要是在開(kāi)啟了SDK的Debug模式下調(diào)用環(huán)信的EMLog.d()方法輸出的日志,日志內(nèi)容都會(huì)在控制臺(tái)輸出的同時(shí)記錄到設(shè)備的日志文件中;
這里就一些常見(jiàn)的日志跟大家略微解釋下,一邊能給大家在以后排查問(wèn)題中起到一些幫助;
PS:這里所列出來(lái)的日志內(nèi)容只是特定情況測(cè)試下出現(xiàn),在不同的設(shè)備,不同環(huán)境下稍微會(huì)有些出入,不過(guò)一些關(guān)鍵詞的地方都應(yīng)該是一樣的,不要死心眼就好;
網(wǎng)絡(luò)相關(guān)
SDK 的初始化
SDK 初始化的時(shí)候會(huì)首先檢查 DNS 配置信息是否存在,如果不存在,在初始化時(shí)會(huì)首先請(qǐng)求 DNS 配置列表,請(qǐng)求成功后就會(huì)返回一個(gè)json串,2.x 是xml格式內(nèi)容;如果當(dāng)對(duì)方的網(wǎng)絡(luò)情況有問(wèn)題的時(shí)候,這一步就可以看出一些問(wèn)題,比如請(qǐng)求 dns 列表失敗等
關(guān)鍵詞:getDnsListFromServer,parseDnsServer,dns_time
[2017/3/1 16:23:31:497]: =============EMChatClientImpl::init()==================
[2017/3/1 16:23:31:497]: dns config mode is 1
[2017/3/1 16:23:31:497]: EMConfigManager::init()
[2017/3/1 16:23:31:497]: No config file, do nothing
[2017/3/1 16:23:31:497]: addConnectionListener
[2017/3/1 16:23:31:499]: =============== Call Manager init ===============
[2017/3/1 16:23:31:499]: addConnectionListener
[2017/3/1 16:23:31:506]: registerContactListener
[2017/3/1 16:23:31:511]: restBaseUrl()
[2017/3/1 16:23:31:511]: EMDNSManager::getCurrentHost: type: 2
[2017/3/1 16:23:31:512]: EMSessionManager::checkDNS()
[2017/3/1 16:23:31:512]: valid_time:
[2017/3/1 16:23:31:512]: no saved dns list, download it
[2017/3/1 16:23:31:514]: getDnsListFromServer()
[2017/3/1 16:23:31:514]: buildUrl(): http://rs.easemob.com/easemob/server.json?sdk_version=3.2.3&app_key=easemob-demo%23chatdemoui&file_version=1
[2017/3/1 16:23:31:631]: [EMARHttpAPI] httpExecute code: 200
[2017/3/1 16:23:31:631]: 1 time retry
[2017/3/1 16:23:31:631]: DNS List size: 2115
[2017/3/1 16:23:31:631]: EMSessionManager::parseDnsServer: {"file_version":"61","resolver":{"hosts":[{"port":"80","domain":"rs.easemob.com","ip":"59.110.89.59"},{"port":"80","domain":"rs.easemob.com","ip":"112.126.66.111"},{"port":"80","domain":"rs.easemob.com","ip":"182.92.174.78"},{"port":"80","domain":"rs.easemob.com","ip":"116.62.83.103"},{"port":"80","domain":"rs.easemob.com","ip":"120.26.17.225"},{"port":"80","domain":"rs.easemob.com","ip":"120.26.15.207"},{"protocol":"https","port":"443","domain":"rs.easemob.com"}]},"rest":{"hosts":[{"protocol":"https","port":"443","domain":"a1.easemob.com"},{"protocol":"http","port":"80","domain":"a1.easemob.com","ip":"182.92.159.193"},{"protocol":"http","port":"80","domain":"a1.easemob.com","ip":"182.92.228.160"},{"protocol":"http","port":"80","domain":"a1.easemob.com","ip":"182.92.0.214"},{"protocol":"http","port":"80","domain":"a1.easemob.com","ip":"182.92.4.52"}]},"valid_before":"1496085791","im":{"hosts":[{"port":"443","domain":"im1.easemob.com","ip":"182.92.20.34"},{"port":"443","domain":"im1.easemob.com","ip":"182.92.20.117"},{"port":"443","domain":"im1.easemob.com","ip":"182.92.23.59"},{"port":"443","domain":"im1.easemob.com","ip":"182.92.26.56"}]},"deploy_name":"easemob","tcp_resolver":{"hosts":[{"port":"2020","domain":"rs.easemob.com","ip":"59.110.89.59"},{"port":"2020","domain":"rs.easemob.com","ip":"112.126.66.111"},{"port":"2020","domain":"rs.easemob.com","ip":"182.92.174.78"},{"port":"2020","domain":"rs.easemob.com","ip":"116.62.83.103"},{"port":"2020","domain":"rs.easemob.com","ip":"120.26.17.225"},{"port":"2020","domain":"rs.easemob.com","ip":"120.26.15.207"}]},"msync-im":{"hosts":[{"port":"6801","domain":"msync-im1.easemob.com","ip":"60.205.131.133"},{"port":"7830","domain":"msync-im1.easemob.com","ip":"60.205.109.58"}]},"xmpp":{"hosts":[{"protocol":"http","port":"80","domain":"im-api.easemob.com","ip":"im-api.easemob.com"},{"protocol":"http","port":"5280","domain":"im-api.easemob.com","ip":"182.92.159.193"},{"protocol":"http","port":"5280","domain":"im-api.easemob.com","ip":"182.92.228.160"},{"protocol":"https","port":"443","domain":"im-api.easemob.com"}]},"gcm_enabled":"true"}
[2017/3/1 16:23:31:631]: current time: 1488356611631
[2017/3/1 16:23:31:631]: valid time: 1496085791000
[2017/3/1 16:23:31:631]: saveConfigs()
[2017/3/1 16:23:31:632]: write to config file: {
"dns_time":"1496085791000"
}
手動(dòng)登錄
當(dāng)進(jìn)行手動(dòng)登錄是,會(huì)首先獲取 DNS 配置,(上邊初始化時(shí)不是已經(jīng)獲取了么,為什么還要獲???因?yàn)?sdk 就這樣寫(xiě)的,所以它又獲取了一次??)如果不存在就去獲取,獲取失敗的情況下會(huì)進(jìn)行多次嘗試,然后獲取完成 DNS 之后就開(kāi)始登錄了,登錄要做的就是獲取賬戶(hù)的 token,后續(xù)的操作都是根據(jù)這個(gè) token 進(jìn)行操作了
主要關(guān)鍵詞:login,getDnsListFromServer,fetchToken,token
[2017/3/1 16:39:6:481]: [EMClient] emchat manager login in process:19581
[2017/3/1 16:39:6:539]: EMSessionManager::login(): lz1
[2017/3/1 16:39:6:539]: getDnsListFromServer()
...
這里會(huì)同樣的去獲取 DNS 配置
...
[2017/3/1 10:1:41:794]: current host: domain: 182.92.0.214 port: 80
[2017/3/1 10:1:41:794]: fetchTokenForUser()http://182.92.0.214:80/shztzn/smartfarm/token
[2017/3/1 10:1:41:895]: [retrieve token time] 0: 0:101
[2017/3/1 10:1:41:895]: fetchToken success
[2017/3/1 10:1:41:895]: saveToken(): user: pad8a7195bffad4b6bdb65e533e969e43c2 time: 1488333701895
[2017/3/1 10:1:41:921]: savetoken() result: 1
[2017/3/1 10:1:41:921]: EMDNSManager::getCurrentHost: type: 1
[2017/3/1 10:1:41:922]: EMSessionManager::checkDNS()
[2017/3/1 10:1:41:922]: EMDNSManager::getHost: type: 1
[2017/3/1 10:1:41:922]: current host: domain: 60.205.131.133 port: 6801
[2017/3/1 10:1:41:922]: token is valid
[2017/3/1 10:1:41:922]: setServer: 60.205.131.133
[2017/3/1 10:1:41:922]: Calling connect...
[2017/3/1 10:1:41:922]: doConnect()
[2017/3/1 10:1:41:922]: current connectState: 0
[2017/3/1 10:1:41:922]: log: level: 0, area: 1, ChatClient::connect()
[2017/3/1 10:1:41:922]: log: level: 0, area: 2, getSocket(): 41
[2017/3/1 10:1:41:922]: log: level: 1, area: 2, connectSocket(): start to connecting...
[2017/3/1 10:1:41:958]: log: level: 1, area: 2, connectSocket(): connect finished
...
自動(dòng)登錄
在3.x中確定自動(dòng)登錄只需要一個(gè)關(guān)鍵詞就好:autoLogin
需要注意一點(diǎn),自動(dòng)登錄和重連不一樣,自動(dòng)登錄包含初始化以及 DNS 的檢測(cè),重連一般不檢測(cè) DNS,自動(dòng)登錄最后輸出的日志基本和重連的一樣,都是進(jìn)行網(wǎng)絡(luò)鏈接;
[2017/3/1 17:30:17:640]: autoLogin
[2017/3/1 17:30:17:641]: EMSessionManager::login(): lz1
[2017/3/1 17:30:17:641]: EMDNSManager::getCurrentHost: type: 1
[2017/3/1 17:30:17:641]: EMSessionManager::checkDNS()
[2017/3/1 17:30:17:641]: valid_time: 1496085791000
[2017/3/1 17:30:17:641]: EMSessionManager::parseDnsServer: autologin
[2017/3/1 17:30:17:642]: current time: 1488360617642
[2017/3/1 17:30:17:642]: valid time: 1496085791000
[2017/3/1 17:30:17:642]: saveConfigs()
[2017/3/1 17:30:17:643]: write to config file: {
"dns_time":"1496085791000"
}
[2017/3/1 17:30:17:649]: checkDNS finished
[2017/3/1 17:30:17:651]: Calling connect...
[2017/3/1 17:30:17:651]: doConnect()
[2017/3/1 17:30:17:651]: current connectState: 0
[2017/3/1 17:30:17:651]: log: level: 0, area: 1, ChatClient::connect()
[2017/3/1 17:30:17:653]: log: level: 0, area: 2, getSocket(): 35
[2017/3/1 17:30:17:653]: log: level: 1, area: 2, connectSocket(): start to connecting...
[2017/3/1 17:30:17:665]: log: level: 1, area: 2, connectSocket(): connect finished
退出登錄
推出的登錄的日志很簡(jiǎn)單,清空一些數(shù)據(jù),然后斷開(kāi)連接等;
關(guān)鍵詞:logout,disconnect,cleanup
[2017/3/1 10:1:39:707]: begin logout ..
[2017/3/1 10:1:39:707]: EMSessionManager::disconnect()
[2017/3/1 10:1:39:707]: clearDnsConfig()
[2017/3/1 10:1:39:707]: logout complete
[2017/3/1 10:1:39:708]: saveConfigs()
[2017/3/1 10:1:39:708]: write to config file: {
"dns_time":"-1"
}
[2017/3/1 10:1:40:265]: stopReceive()
[2017/3/1 10:1:40:265]: log: level: 0, area: 1, ChatClient::disconnect()
[2017/3/1 10:1:40:265]: log: level: 1, area: 2, cleanup() 41
[2017/3/1 10:1:40:265]: log: level: 1, area: 2, closeSocket() 41
[2017/3/1 10:1:40:265]: log: level: 2, area: 1, handleDisconnect:14
心跳定時(shí)器
一切都準(zhǔn)備好了之后,就是定義心跳定時(shí)器,第一次設(shè)置時(shí)2'00"后啟動(dòng)心跳定時(shí)器,后邊會(huì)慢慢增加到4'30",然后會(huì)按照4'30"這樣循環(huán)下去
[2017/3/1 16:39:7:52]: [smart ping] change smart ping state from : EMReady to : EMEvaluating
[2017/3/1 16:39:7:52]: [smart ping] reset interval...
[2017/3/1 16:39:7:52]: [smart ping] change smart ping state from : EMEvaluating to : EMEvaluating
[2017/3/1 16:39:7:55]: [smart ping] onConnectred ...
[2017/3/1 16:39:7:55]: [smart ping] reset interval...
[2017/3/1 16:39:7:66]: [smart ping] prevWifi:false isWifi:true prevWIFISSID: SSID"huanxin-unifi"
[2017/3/1 16:39:7:67]: [smart ping] change smart ping state from : EMEvaluating to : EMEvaluating
[2017/3/1 16:39:7:68]: [smart ping] reset currentInterval:02:00:000
[2017/3/1 16:39:7:68]: [smart ping] schedule next alarm
[2017/3/1 16:39:7:68]: [smart ping] current heartbeat interval : 02:00:000 smart ping state : EMEvaluating
鏈接監(jiān)聽(tīng)與重連
連接監(jiān)聽(tīng)主要是實(shí)現(xiàn) EMConnectionListener 接口來(lái)監(jiān)聽(tīng)設(shè)備和服務(wù)器的連接情況,其中牽扯到網(wǎng)絡(luò)恢復(fù)后與服務(wù)器的重連,下邊這部分日志是當(dāng)檢測(cè)到網(wǎng)絡(luò)連接斷開(kāi)后,SDK和服務(wù)器的連接情況,下邊的日志中當(dāng)SDK 檢測(cè)到鏈接不到服務(wù)器后會(huì)首先清空 socket 等一些鏈接相關(guān)信息,然后會(huì)回到鏈接監(jiān)聽(tīng)的onDisConnect()方法,接著 SDK 會(huì)進(jìn)行嘗試重連 3 次,當(dāng)嘗試全部失敗后就不在嘗試,會(huì)安排一個(gè)定時(shí)器,定時(shí)器的時(shí)間是2'45",到時(shí)間后會(huì)觸發(fā)心跳重新進(jìn)行嘗試連接服務(wù)器,如果在這個(gè)心跳觸發(fā)之前,網(wǎng)絡(luò)狀況有新的變化會(huì)直接重新嘗試連接服務(wù)器;
關(guān)鍵詞:onDisconnect,disconnect,onNetworkChanged,EMHeartBeatReceiver,heartbeat,reconnect,doConnect
[2017/3/1 19:30:28:214]: log: level: 1, area: 2, cleanup() 34
[2017/3/1 19:30:28:214]: log: level: 1, area: 2, closeSocket() 34
[2017/3/1 19:30:28:214]: log: level: 2, area: 2, recv(): recv() failed. errno: 110: Connection timed out
[2017/3/1 19:30:28:214]: log: level: 1, area: 2, cleanup() -1
[2017/3/1 19:30:28:214]: log: level: 2, area: 1, handleDisconnect:1
[2017/3/1 19:30:28:214]: EMSessionManager::onDisConnect(): 1
[2017/3/1 19:30:28:214]: stopReceive()
[2017/3/1 19:30:28:214]: log: level: 0, area: 1, ChatClient::disconnect()
[2017/3/1 19:30:28:214]: log: level: 1, area: 2, cleanup() -1
[2017/3/1 19:30:28:214]: log: level: 2, area: 1, handleDisconnect:14
[2017/3/1 19:30:28:214]: network issue, just reconnect after random time
[2017/3/1 19:30:28:215]: EMSessionManager::scheduleReconnect() updateServer: 0 updateToken: 0
[2017/3/1 19:30:28:215]: EMSessionManager::delayReconnect()
[2017/3/1 19:30:28:215]: getDelayedTime(): 7
[2017/3/1 19:30:28:215]: notify state change to connection listener
[2017/3/1 19:30:28:216]: [global listener] onDisconnect303
[2017/3/1 19:30:28:216]: [smart ping] onDisconnected ...303
[2017/3/1 19:30:28:616]: [EMClient] connectivity receiver onReceiver
[2017/3/1 19:30:28:629]: [EMClient] no data connection
[2017/3/1 19:30:28:630]: onNetworkChanged(): 0
[2017/3/1 19:30:28:630]: notify network broken
[2017/3/1 19:30:28:630]: EMSessionManager::disconnect()
[2017/3/1 19:30:28:632]: notify state change to connection listener
[2017/3/1 19:30:28:632]: [global listener] onDisconnect2
[2017/3/1 19:30:28:632]: [smart ping] onDisconnected ...2
[2017/3/1 19:30:31:440]: [EMClient] connectivity receiver onReceiver
[2017/3/1 19:30:31:447]: [EMClient] no data connection
[2017/3/1 19:30:31:447]: onNetworkChanged(): 0
[2017/3/1 19:30:31:447]: notify network broken
[2017/3/1 19:30:31:447]: EMSessionManager::disconnect()
[2017/3/1 19:30:31:448]: notify state change to connection listener
[2017/3/1 19:30:31:449]: [global listener] onDisconnect2
[2017/3/1 19:30:31:449]: [smart ping] onDisconnected ...2
[2017/3/1 19:30:31:492]: [EMClient] connectivity receiver onReceiver
[2017/3/1 19:30:31:511]: [EMClient] no data connection
[2017/3/1 19:30:31:511]: onNetworkChanged(): 0
[2017/3/1 19:30:31:511]: notify network broken
[2017/3/1 19:30:31:512]: EMSessionManager::disconnect()
[2017/3/1 19:30:31:512]: notify state change to connection listener
[2017/3/1 19:30:31:512]: [global listener] onDisconnect2
[2017/3/1 19:30:31:512]: [smart ping] onDisconnected ...2
[2017/3/1 19:33:4:560]: [EMHeartBeatReceiver] onReceive EMHeartBeatReceiver
[2017/3/1 19:33:4:567]: [net] no data connection
[2017/3/1 19:33:4:570]: [smart ping] schedule next alarm
[2017/3/1 19:33:4:573]: [smart ping] current heartbeat interval : 02:45:000 smart ping state : EMEvaluating
[2017/3/1 19:33:4:579]: [net] no data connection
[2017/3/1 19:33:4:580]: [smart ping] is not connected to server, so use idle interval : 3 mins
[2017/3/1 19:36:19:566]: [EMClient] connectivity receiver onReceiver
[2017/3/1 19:36:19:577]: [net] wifi is connected
[2017/3/1 19:36:19:577]: [EMClient] has wifi connection
[2017/3/1 19:36:19:577]: onNetworkChanged(): 2
[2017/3/1 19:36:19:577]: network comes back, retry to connect
[2017/3/1 19:36:19:577]: EMSessionManager::reconnect()
[2017/3/1 19:36:19:577]: doConnect()
[2017/3/1 19:36:19:577]: current connectState: 0
[2017/3/1 19:36:19:577]: log: level: 0, area: 1, ChatClient::connect()
[2017/3/1 19:36:19:596]: log: level: 0, area: 2, getSocket(): 67
[2017/3/1 19:36:19:596]: log: level: 1, area: 2, connectSocket(): start to connecting...
[2017/3/1 19:36:19:602]: log: level: 1, area: 2, connectSocket(): connect finished
被踢&強(qiáng)制下線&移除賬戶(hù)
和賬戶(hù)相關(guān)的操作其實(shí)也都是以消息的形式和服務(wù)器進(jìn)行交互的,其中一個(gè)特殊屬性為ns,類(lèi)型是STATISTIC,然后具體的操作通過(guò) operation進(jìn)行細(xì)分:1.表示移除/禁用/強(qiáng)制下線,2.表示異地登錄
這幾個(gè)狀態(tài)都會(huì)觸發(fā)網(wǎng)絡(luò)鏈接監(jiān)聽(tīng)的斷開(kāi)onDisconnect()回調(diào);
PS:需要注意的一點(diǎn)就是,當(dāng)收到這幾個(gè)狀態(tài)的回調(diào)后需要手動(dòng)調(diào)用logout,清除當(dāng)前登錄狀態(tài),因此在遇到被踢和強(qiáng)制下線的日志中一般都能看到和 logout 相關(guān)日志
關(guān)鍵詞:STATISTIC,operation,logout,onDisconnected,206,heart beat
異地登錄
[2017/3/1 20:0:26:592]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { metas : [ { id : 304104413746698288, from : @easemob.com, to : easemob-demo#chatdemoui_lz1@easemob.com/mobile, timestamp : 1488369626401, ns : STATISTIC, payload : { operation : 2 } } ], queue : @easemob.com } }
[2017/3/1 20:0:26:592]: log: level: 0, area: 1, ChatClient::disconnect()
[2017/3/1 20:0:26:592]: log: level: 1, area: 2, cleanup() 35
[2017/3/1 20:0:26:592]: log: level: 1, area: 2, closeSocket() 35
[2017/3/1 20:0:26:592]: log: level: 2, area: 1, handleDisconnect:13
[2017/3/1 20:0:26:592]: EMSessionManager::onDisConnect(): 13
[2017/3/1 20:0:26:592]: stopReceive()
[2017/3/1 20:0:26:592]: log: level: 0, area: 1, ChatClient::disconnect()
[2017/3/1 20:0:26:592]: log: level: 1, area: 2, cleanup() -1
[2017/3/1 20:0:26:592]: log: level: 2, area: 1, handleDisconnect:14
[2017/3/1 20:0:26:593]: ConnUserLoginAnotherDevice
[2017/3/1 20:0:26:593]: begin logout ..
[2017/3/1 20:0:26:593]: EMSessionManager::disconnect()
[2017/3/1 20:0:26:593]: clearDnsConfig()
[2017/3/1 20:0:26:593]: logout complete
[2017/3/1 20:0:26:593]: notify state change to connection listener
[2017/3/1 20:0:26:618]: [smart ping] onDisconnected ...206
[2017/3/1 20:0:26:640]: [EMPushHelper] push notification helper ondestory
[2017/3/1 20:0:26:641]: [EMClient] SDK Logout
[2017/3/1 20:0:26:643]: [smart ping] stop heart beat timer
[2017/3/1 20:0:26:643]: [smart ping] change smart ping state from : EMEvaluating to : EMStopped
[2017/3/1 20:0:26:644]: [smart ping] reset interval...
[2017/3/1 20:0:26:645]: [smart ping] change smart ping state from : EMStopped to : EMEvaluating
[2017/3/1 20:0:26:650]: logout, user not login
[2017/3/1 20:0:26:650]: saveConfigs()
[2017/3/1 20:0:26:651]: write to config file: {
"dns_time":"-1"
}
移除/禁用/強(qiáng)制下線
[2017/3/2 14:14:55:351]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { metas : [ { id : 304386456690886672, from : @easemob.com, to : easemob-demo#chatdemoui_lz1@easemob.com/mobile, timestamp : 1488435294646, ns : STATISTIC, payload : { operation : 1 } } ], queue : @easemob.com } }
網(wǎng)絡(luò)有問(wèn)題的日志 TODO
下邊這段日志是在當(dāng)前網(wǎng)絡(luò)有問(wèn)題的情況下進(jìn)行登錄請(qǐng)求,可以看到請(qǐng)求結(jié)果是408,正常情況重連服務(wù)器是不需要獲取DNS 的,但是這個(gè)應(yīng)該是 DNS 配置已經(jīng)失效,這邊一直在嘗試重新獲取 DNS;不過(guò)從后邊的日志可以看出是網(wǎng)絡(luò)連接有問(wèn)題;
關(guān)鍵詞:disconnect,handleDisconnect,checkDNS,408,reconnect,unreachable
[2017/3/1 9:59:52:649]: log: level: 0, area: 1, ChatClient::disconnect()
[2017/3/1 9:59:52:649]: log: level: 1, area: 2, cleanup() -4
[2017/3/1 9:59:52:649]: log: level: 2, area: 1, handleDisconnect:14
[2017/3/1 9:59:52:649]: dns error, reconnect using different IP
[2017/3/1 9:59:52:649]: EMSessionManager::scheduleReconnect() updateServer: 1 updateToken: 0
[2017/3/1 9:59:52:649]: EMDNSManager::getNextAvailableHost: type: 1
[2017/3/1 9:59:52:649]: EMSessionManager::checkDNS()
[2017/3/1 9:59:52:649]: tried all candidates, download again
[2017/3/1 9:59:52:649]: getDnsListFromServer()
[2017/3/1 9:59:52:649]: EMDNSManager::getHost: type: 0
[2017/3/1 9:59:52:649]: current host: domain: 120.26.17.225 port: 80
[2017/3/1 9:59:52:649]: buildUrl(): http://120.26.17.225/easemob/server.json?sdk_version=3.2.3&app_key=shztzn%23smartfarm&file_version=61
[2017/3/1 9:59:52:651]: notify state change to connection listener
[2017/3/1 9:59:52:664]: 1 time retry
[2017/3/1 9:59:52:664]: getDnsListFromServer code: 408 response:
[2017/3/1 9:59:52:664]: EMDNSManager::getHost: type: 0
[2017/3/1 9:59:52:665]: current host: domain: 59.110.89.59 port: 80
[2017/3/1 9:59:52:665]: buildUrl(): http://59.110.89.59/easemob/server.json?sdk_version=3.2.3&app_key=shztzn%23smartfarm&file_version=61
[2017/3/1 9:59:52:673]: 2 time retry
[2017/3/1 9:59:52:673]: getDnsListFromServer code: 408 response:
[2017/3/1 9:59:52:674]: EMDNSManager::getHost: type: 0
[2017/3/1 9:59:52:674]: current host: domain: 112.126.66.111 port: 80
[2017/3/1 9:59:52:674]: buildUrl(): http://112.126.66.111/easemob/server.json?sdk_version=3.2.3&app_key=shztzn%23smartfarm&file_version=61
[2017/3/1 9:59:52:674]: EMDNSManager::getNextAvailableHost: new index: 0
[2017/3/1 9:59:52:675]: EMDNSManager::getHost: type: 1
[2017/3/1 9:59:52:675]: current host: domain: 60.205.131.133 port: 6801
[2017/3/1 9:59:52:675]: setServer: 60.205.131.133
[2017/3/1 9:59:52:676]: EMSessionManager::delayReconnect()
[2017/3/1 9:59:52:676]: getDelayedTime(): 17
[2017/3/1 9:59:52:676]: Calling connect result: 0
[2017/3/1 9:59:53:505]: asyncSendMessage: 14883335935043542 retry = 3
[2017/3/1 9:59:53:505]: EMSessionManager::reconnect()
[2017/3/1 9:59:53:506]: doConnect()
[2017/3/1 9:59:53:506]: current connectState: 0
[2017/3/1 9:59:53:506]: log: level: 0, area: 1, ChatClient::connect()
[2017/3/1 9:59:53:506]: log: level: 0, area: 2, getSocket(): 41
[2017/3/1 9:59:53:506]: log: level: 1, area: 2, connectSocket(): start to connecting...
[2017/3/1 9:59:53:508]: log: level: 2, area: 2, connectSocket(): 60.205.131.133 error: Network is unreachable
[2017/3/1 9:59:53:508]: log: level: 1, area: 2, closeSocket() 41
[2017/3/1 9:59:53:508]: log: level: 1, area: 2, connectSocket(): connect finished
[2017/3/1 9:59:53:508]: log: level: 2, area: 2, connect(): connection refused
[2017/3/1 9:59:53:508]: log: level: 1, area: 2, cleanup() -4
[2017/3/1 9:59:53:508]: log: level: 2, area: 1, handleDisconnect:4
[2017/3/1 9:59:53:508]: EMSessionManager::onDisConnect(): 4
[2017/3/1 9:59:53:508]: stopReceive()
推送相關(guān)
和推送相關(guān)的日志都是和EMPushHelper或者EMPushManager相關(guān)的,可以從日志中看到推送功能是否激活,然后獲取devicetoken發(fā)送到服務(wù)器等,devicetoken這個(gè)值一定要存在,否者推送無(wú)效;這些可以作為檢測(cè)集成離線推送本地設(shè)置是否有效的一些手段;
關(guān)鍵詞:GCM,push,devicetoken,sendDeviceToServer
[2017/3/1 16:39:7:202]: isEnabledGCM: 1
[2017/3/1 16:39:7:202]: [EMPushHelper] GCM is enabled : true
[2017/3/1 16:39:7:207]: [EMPushHelper] GCM service available : false
[2017/3/1 16:39:7:217]: [EMPushHelper] mipush available : true
[2017/3/1 16:39:7:218]: [EMPushHelper] third-party push available
[2017/3/1 16:39:7:221]: [EMPushManager] nick name is null or empty
[2017/3/1 16:39:7:708]: [EMMipushReceiver] mi push reigster success
[2017/3/1 16:39:7:708]: [EMPushHelper] devicetoken = /cRO2vRH64mWOH46+We1zxt4+onQRJOe26fvcX02iC0=
[2017/3/1 16:39:7:715]: [HttpClientManager] try send request, request url: http://182.92.4.52:80/easemob-demo/chatdemoui/devices with number: 0
[2017/3/1 16:39:7:792]: [EMPushHelper] sendDeviceToServer SC_OK:
修改離線推送相關(guān)
[2017/3/2 13:11:53:423]: SetGroupsOfNotificationDisabled 1
[2017/3/2 13:11:53:564]: update user configs: {
"action" : "put",
"application" : "4d7e4ba0-dc4a-11e3-90d5-e1ffbaacdaf5",
"path" : "/users",
"uri" : "https://a1.easemob.com/easemob-demo/chatdemoui/users",
"entities" : [ {
"uuid" : "479d9cea-134d-11e6-8943-534ab75c4508",
"type" : "user",
"created" : 1462513331630,
"modified" : 1488431513381,
"username" : "lz1",
"activated" : true,
"notification_display_style" : 1,
"device_token" : "/cRO2vRH64mWOH46+We1zxt4+onQRJOe26fvcX02iC0=",
"nickname" : "立正1",
"notification_ignore_1479267663683" : true,
"notification_ignore_1483610597352" : true,
"notification_ignore_1488431342804" : false,
"notifier_name" : "2882303761517426801"
} ],
"timestamp" : 1488431513377,
"duration" : 33,
"organization" : "easemob-demo",
"applicationName" : "chatdemoui"
}
消息相關(guān)
消息相關(guān)的日志還是比較明確的,
發(fā)送消息
發(fā)送新消息時(shí)會(huì)首先生成一個(gè)臨時(shí)的 msgId,這個(gè) msgId 是當(dāng)前時(shí)間戳+四位拼成;當(dāng)消息發(fā)送成功后,服務(wù)器會(huì)返回對(duì)應(yīng)的服務(wù)器生成的 msgId 然后更新到本地,這算是一個(gè)消息的發(fā)送完成(可以根據(jù)這部分來(lái)判斷消息是否發(fā)送成功);
然后如果開(kāi)啟了已讀回執(zhí),當(dāng)對(duì)方讀了消息之后,發(fā)送者會(huì)收到一條通知(NOYICE 的消息)告訴你有因消息,因?yàn)?ack 也是新消息,所以也是需要自己去服務(wù)器同步拉?。ㄗ⒁馊罩局械?REAF_ACK);當(dāng)做完這些之后,SDK 會(huì)重新發(fā)一條同步的消息,來(lái)看下是否還有新的消息
關(guān)鍵詞:asyncSendMessage,SEND,RECV,NOTICE,server_id,READ_ACK
[2017/3/1 21:7:0:649]: asyncSendMessage: 14883736206090002 retry = 3
[2017/3/1 21:7:0:650]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 14883736206090002, to : lz2, ns : CHAT, payload : { chattype : CHAT, from : lz1, to : lz2, contents : [ { contenttype : TEXT, text : www問(wèn)問(wèn) } ] } } } }
消息發(fā)送成功,返回服務(wù)器生成的 msgId
[2017/3/1 21:7:0:743]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, meta_id : 14883736206090002, server_id : 304121568710101040, timestamp : 1488373620639 } }
服務(wù)器告訴 SDK 有新消息了
[2017/3/1 21:7:1:314]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : NOTICE, payload : { queue : lz2/mobile } }
發(fā)送請(qǐng)求來(lái)同步新消息
[2017/3/1 21:7:1:314]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { queue : lz2/mobile } }
收到已讀的 ACK
[2017/3/1 21:7:1:333]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304121571285403696, timestamp : 1488373621196, ns : CHAT, payload : { chattype : READ_ACK, from : lz2, to : lz1, ack_message_id : 304121568710101040 } } ], next_key : 304121571285403696, queue : lz2, timestamp : 1488373621267 } }
查詢(xún)是否還有新消息
[2017/3/1 21:7:1:333]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { key : 304121571285403696, queue : lz2 } }
[2017/3/1 21:7:1:515]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, queue : lz2, is_last : true, timestamp : 1488373621351 } }
...
發(fā)送已讀 ACK
[2017/3/2 11:7:8:116]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 775, to : admin, ns : CHAT, payload : { chattype : READ_ACK, from : lz1, to : admin, ack_message_id : 304337511725925492 } } } }
收到新消息
3.x收到新消息后服務(wù)器并不會(huì)直接下發(fā)消息,而是給SDK端下發(fā)一個(gè)通知(NOTICE 的消息),告訴你有新消息,就像下邊日志的第一行,sdk 收到這條消息之后,會(huì)給服務(wù)器發(fā)送一個(gè)我要獲取新消息的消息(有點(diǎn)繞),然后服務(wù)器才會(huì)把這條消息給下發(fā),當(dāng)接收完這次通知的消息后,SDK 還會(huì)給服務(wù)器在發(fā)送一條同步消息,用來(lái)詢(xún)問(wèn)服務(wù)器是否還有新的消息,當(dāng)返回結(jié)果包含is_last:true時(shí),表示已經(jīng)沒(méi)有新消息;
當(dāng)消息接收完成之后就是SDK內(nèi)部給上層發(fā)送通知了;最后就是當(dāng)自己看了新消息之后,還要給對(duì)方發(fā)送一條ACK 的信息,然后還要收到一條服務(wù)器返回的一條狀態(tài)信息才算完事;
關(guān)鍵詞:RECV,NOTICE,CHAT,compress_algorimth,callbackReceievedMessages,onMessageReceived,COMMAND,action,READ_ACK,is_last
服務(wù)器告訴 SDK 有新消息了
[2017/3/1 20:58:54:6]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : NOTICE, payload : { queue : lz2/mobile } }
發(fā)送請(qǐng)求來(lái)同步新消息
[2017/3/1 20:58:54:6]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { queue : lz2/mobile } }
[2017/3/1 20:58:54:32]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304119478168324144, timestamp : 1488373133870, ns : CHAT, payload : { chattype : CHAT, from : lz2, to : lz1, contents : [ { contenttype : TEXT, text : qqqqqqqqqqqq } ] } } ], next_key : 304119478168324144, queue : lz2, timestamp : 1488373133959 } }
查詢(xún)是否還有新消息
[2017/3/1 20:58:54:32]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { key : 304119478168324144, queue : lz2 } }
[2017/3/1 20:58:54:106]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, queue : lz2, is_last : true, timestamp : 1488373134006 } }
發(fā)送 ACK 給對(duì)方
[2017/3/1 21:5:55:298]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 259, to : lz2, ns : CHAT, payload : { chattype : READ_ACK, from : lz1, to : lz2, ack_message_id : 304119478168324144 } } } }
[2017/3/1 21:5:55:364]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, meta_id : 259, server_id : 304121288056637488, timestamp : 1488373555277 } }
收到 cmd 消息
[2017/3/2 11:6:13:653]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304337832351106168, timestamp : 1488423973404, ns : CHAT, payload : { chattype : CHAT, from : admin, to : lz1, contents : [ { contenttype : COMMAND, action : action1 } ] } } ], next_key : 304337832351106168, queue : admin, timestamp : 1488423973440 } }
收到離線消息,這個(gè)直接是一個(gè) json 數(shù)組
[2017/3/2 12:46:37:98]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304343301819992124, timestamp : 1488425246875, ns : CHAT, payload : { chattype : CHATROOM, from : qazqaz123321, to : 3759501541378, contents : [ { contenttype : VOICE, displayname : qazqaz12332120170302T112724.amr, remotepath : https://a1.easemob.com/easemob-demo/chatdemoui/chatfiles/289e8240-fef8-11e6-b120-0b193a44693b, secretkey : KJ6CSv74EeacsQ3KDqwnqF9amIMbc6fNBK-qXRVNwd4MkZR7, filelength : 2134, duration : 2 } ] } }, { id : 304343752070137864, timestamp : 1488425351703, ns : CHAT, payload : { chattype : CHATROOM, from : lingo, to : 3759501541378, contents : [ { contenttype : VOICE, displayname : lingo20170302T112907.amr, remotepath : https://a1.easemob.com/easemob-demo/chatdemoui/chatfiles/671458b0-fef8-11e6-bf54-a356d485d240, secretkey : ZxRYuv74EeankPOIMACFAftORz04rIiMWfHPQUKLvcXi_Jgo, filelength : 2566, duration : 3 } ] } }, { id : 304345086324377616, timestamp : 1488425662350, ns : CHAT, payload : { chattype : CHATROOM, from : 15515625700, to : 3759501541378, contents : [ { contenttype : TEXT, text : [):] } ], exts : [ { key : userIcon, type : 7, value : https://116.255.227.78:1008/FileUpload/UserImage/7521a766-64db-4a18-8772-d22c5e065d0b.jpg }, { key : userName, type : 7, value : hl_4a8fe2f } ] } }, { id : 304347342838958040, timestamp : 1488426187748, ns : CHAT, payload : { chattype : CHATROOM, from : kimpeng, to : 3759501541378, contents : [ { contenttype : TEXT, text : [+o(] } ] } }, { id : 304347456840140856, timestamp : 1488426214277, ns : CHAT, payload : { chattype : CHATROOM, from : 15172330957, to : 3759501541378, contents : [ { contenttype : TEXT, text : 基本 } ] } }, { id : 304348603307001816, timestamp : 1488426481208, ns : CHAT, payload : { chattype : CHATROOM, from : kimpeng, to : 3759501541378, contents : [ { contenttype : TEXT, text : [:(] } ] } }, { id : 304349346936129496, timestamp : 1488426654367, ns : CHAT, payload : { chattype : CHATROOM, from : kimpeng, to : 3759501541378, contents : [ { contenttype : TEXT, text : [:(][(a)] } ] } }, { id : 304349681360570328, timestamp : 1488426732212, ns : CHAT, payload : { chattype : CHATROOM, from : kimpeng, to : 3759501541378, contents : [ { contenttype : TEXT, text : A } ] } }, { id : 304350070763947992, timestamp : 1488426822893, ns : CHAT, payload : { chattype : CHATROOM, from : kimpeng, to : 3759501541378, contents : [ { contenttype : TEXT, text : A } ] } }, { id : 304350107678017496, timestamp : 1488426831478, ns : CHAT, payload : { chattype : CHATROOM, from : kimpeng, to : 3759501541378, contents : [ { contenttype : TEXT, text : A } ] } }, { id : 304363701610219560, timestamp : 1488429996565, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_3759501541378@conference.easemob.com, operation : JOIN, from : easemob-demo#chatdemoui_lz1@easemob.com, status : { error_code : 0, description : } } } ], next_key : 304363701610219560, queue : 3759501541378@conference.easemob.com, timestamp : 1488429996918 } }
業(yè)務(wù)邏輯相關(guān)
在3.x 中一切的操作都是用消息的形式來(lái)做的,通過(guò)發(fā)送代表特定操作的消息給服務(wù)器,然后服務(wù)器會(huì)返回這個(gè)消息發(fā)送成功,接著服務(wù)器會(huì)以新消息的形式告訴 SDK 操作成功,最后都和收發(fā)消息的日志邏輯一樣;
需要注意的就是這些操作中的關(guān)鍵詞;
首先說(shuō)一點(diǎn)就是,這些操作都有一個(gè)特殊的屬性 ns這個(gè)屬性的指表示不同的操作:MUC表示群組和聊天室相關(guān)操作;ROSTER表示聯(lián)系人相關(guān)操作
下邊先用創(chuàng)建新群組來(lái)詳細(xì)解釋下:
創(chuàng)建新群組
從創(chuàng)建群組可以看出,創(chuàng)建的操作就是給服務(wù)器發(fā)送一個(gè)創(chuàng)建的操作,接著服務(wù)器返回這條消息發(fā)送成功,然后就像收到消息一樣,服務(wù)器告訴創(chuàng)建者,你有新消息需要拉取,拉取到后可以發(fā)現(xiàn),這條消息就是告訴自己群組創(chuàng)建成功,然后后邊就是檢查是否有新消息;
關(guān)鍵詞:MUC,SEND,CREATE,RECV,
[2017/3/2 12:7:35:249]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 2567, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488427655248, operation : CREATE, from : lz1, setting : { name : ttttt, desc : tttttt, muc_type : 2, max_users : 200, owner : lz1 }, reason : lz1邀請(qǐng)加入群:ttttt } } } }
[2017/3/2 12:7:35:316]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, meta_id : 2567, server_id : 304353645141428264, timestamp : 1488427655125 } }
[2017/3/2 12:7:35:317]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : NOTICE, payload : { queue : 1488427655248@conference.easemob.com } }
[2017/3/2 12:7:35:317]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { queue : 1488427655248@conference.easemob.com } }
[2017/3/2 12:7:35:372]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304353645279840296, timestamp : 1488427655132, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488427655248@conference.easemob.com, operation : CREATE, from : easemob-demo#chatdemoui_lz1@easemob.com, status : { error_code : 0, description : } } } ], next_key : 304353645279840296, queue : 1488427655248@conference.easemob.com, timestamp : 1488427655190 } }
[2017/3/2 12:7:35:373]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { key : 304353645279840296, queue : 1488427655248@conference.easemob.com } }
[2017/3/2 12:7:35:453]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, queue : 1488427655248@conference.easemob.com, is_last : true, timestamp : 1488427655254 } }
群組其他操作
關(guān)鍵詞:MUC,operation,SEND,APPLY,INVITE,INVITE_ACCEPT,INVITE_DECLINE,APPLY_ACCEPT,APPLY_DECLINE``PRESENCE,LEAVE,DESTROY,KICK,ABSENCE,RECV,BLOCK,UNBLOCK
發(fā)送加入請(qǐng)求:
[2017/3/2 12:26:38:737]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 3591, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488428778313, operation : APPLY, from : lz1, tos : [ lz2 ], reason : 請(qǐng)求加入 } } } }
收到加入請(qǐng)求:
[2017/3/2 12:16:48:410]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304356020619053112, timestamp : 1488428208185, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488427655248@conference.easemob.com, operation : APPLY, from : easemob-demo#chatdemoui_lz2@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], reason : 請(qǐng)求加入, is_chatroom : false, status : { error_code : 0, description : } } } ], next_key : 304356020619053112, queue : lz2, timestamp : 1488428208229 } }
邀請(qǐng)加入群組
[2017/3/2 11:39:39:774]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 2055, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1483610597352, operation : INVITE, from : lz1, tos : [ lz2 ], reason : welcome } } } }
[2017/3/2 11:39:41:64]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304346454208546772, timestamp : 1488425980847, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1483610597352@conference.easemob.com, operation : INVITE_ACCEPT, from : easemob-demo#chatdemoui_lz2@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], is_chatroom : false, status : { description : } } } ], next_key : 304346454208546772, queue : 1483610597352@conference.easemob.com, timestamp : 1488425980883 } }
[2017/3/2 11:39:41:138]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304346454330181588, timestamp : 1488425980876, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1483610597352@conference.easemob.com, operation : PRESENCE, from : easemob-demo#chatdemoui_lz2@easemob.com, is_chatroom : false } } ], next_key : 304346454330181588, queue : 1483610597352@conference.easemob.com, timestamp : 1488425980928 } }
同意對(duì)方邀請(qǐng)
[2017/3/2 12:20:41:289]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 2823, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488427655248, operation : APPLY_ACCEPT, from : lz1, tos : [ lz2 ] } } } }
[2017/3/2 12:20:42:696]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304357026689980384, timestamp : 1488428442436, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488427655248@conference.easemob.com, operation : PRESENCE, from : easemob-demo#chatdemoui_lz2@easemob.com, is_chatroom : false } } ], next_key : 304357026689980384, queue : 1488427655248@conference.easemob.com, timestamp : 1488428442505 } }
拒絕對(duì)方邀請(qǐng)
[2017/3/2 12:21:34:594]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 3335, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488427655248, operation : APPLY_DECLINE, from : lz1, tos : [ lz2 ] } } } }
離開(kāi)群組
[2017/3/2 11:7:24:803]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 1031, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1482203912329, operation : LEAVE, from : lz1 } } } }
[2017/3/2 11:7:25:183]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304338138476578856, timestamp : 1488424044686, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1482203912329@conference.easemob.com, operation : LEAVE, from : easemob-demo#chatdemoui_lz1@easemob.com, status : { error_code : 0, description : } } } ], next_key : 304338138476578856, queue : 1482203912329@conference.easemob.com, timestamp : 1488424044990 } }
群組踢人
[2017/3/2 11:30:40:684]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 1799, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1483610597352, operation : KICK, from : lz1, tos : [ lz2 ] } } } }
[2017/3/2 11:30:41:122]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304344134942984200, timestamp : 1488425440851, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1483610597352@conference.easemob.com, operation : ABSENCE, from : easemob-demo#chatdemoui_lz2@easemob.com, is_chatroom : false } } ], next_key : 304344134942984200, queue : 1483610597352@conference.easemob.com, timestamp : 1488425440955 } }
服務(wù)器刪除群組
[2017/3/2 13:0:44:727]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304367343482439644, timestamp : 1488430844502, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488427655248@conference.easemob.com, operation : DESTROY, from : easemob-demo#chatdemoui_系統(tǒng)管理員@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], is_chatroom : false, status : { error_code : 0, description : } } } ], next_key : 304367343482439644, queue : 1488427655248@conference.easemob.com, timestamp : 1488430844552 } }
屏蔽群消息
[2017/3/2 13:10:23:189]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 5895, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488431342804, operation : BLOCK, from : lz1 } } } }
[2017/3/2 13:10:23:278]: log: level: 1, area: 1, ChatClient::handleSync begin
[2017/3/2 13:10:23:278]: log: level: 1, area: 1, ChatClient::handleSync complete: response
[2017/3/2 13:10:23:310]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304369828473346088, timestamp : 1488431423075, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488431342804@conference.easemob.com, operation : BLOCK, from : easemob-demo#chatdemoui_lz1@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], status : { error_code : 0, description : } } } ], next_key : 304369828473346088, queue : 1488431342804@conference.easemob.com, timestamp : 1488431423128 } }
解除屏蔽群消息
[2017/3/2 15:3:29:333]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 521, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488431342804, operation : UNBLOCK, from : lz1 } } } }
[2017/3/2 15:3:32:900]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304398975526508532, timestamp : 1488438209409, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_1488431342804@conference.easemob.com, operation : UNBLOCK, from : easemob-demo#chatdemoui_lz1@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], status : { error_code : 0, description : } } } ], next_key : 304398975526508532, queue : 1488431342804@conference.easemob.com, timestamp : 1488438210535 } }
聊天室
單單從日志看,這些操作其實(shí)和群組的都一樣
關(guān)鍵詞:MUC,JOIN,PRESENCE,ABSENCE,KICK
自己加入聊天室
[2017/3/2 12:46:36:668]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 5383, to : @easemob.com, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_3759501541378@conference.easemob.com, operation : JOIN, from : lz1 } } } }
收到別人加入聊天室的回調(diào)
[2017/3/2 12:53:40:186]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304365519564179492, timestamp : 1488430419846, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_3759501541378@conference.easemob.com, operation : PRESENCE, from : easemob-demo#chatdemoui_lz2@easemob.com, is_chatroom : true } } ], next_key : 304365519564179492, queue : 3759501541378@conference.easemob.com, timestamp : 1488430420020 } }
其他人離開(kāi)聊天室回調(diào)
[2017/3/2 12:56:56:655]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304366363252623336, timestamp : 1488430616269, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_3759501541378@conference.easemob.com, operation : ABSENCE, from : easemob-demo#chatdemoui_lz2@easemob.com, is_chatroom : true } } ], next_key : 304366363252623336, queue : 3759501541378@conference.easemob.com, timestamp : 1488430616481 } }
自己被后臺(tái)踢出聊天室
[2017/3/2 12:58:30:329]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304366766241351692, timestamp : 1488430710093, ns : MUC, payload : { muc_id : easemob-demo#chatdemoui_3759501541378@conference.easemob.com, operation : KICK, from : easemob-demo#chatdemoui_系統(tǒng)管理員@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], is_chatroom : true, status : { error_code : 0, description : } } } ], next_key : 304366766241351692, queue : 3759501541378@conference.easemob.com, timestamp : 1488430710153 } }
聯(lián)系人
關(guān)鍵詞:ROSTER,ADD,REMOVE,ACCEPT,REMOTE_ACCEPT,DECLINE,REMOTE_DECLINE,BAN
收到添加請(qǐng)求
[2017/3/2 12:31:51:693]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304359900245395412, timestamp : 1488429111488, ns : ROSTER, payload : { operation : ADD, from : easemob-demo#chatdemoui_lz2@easemob.com/mobile, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], reason : 加個(gè)好友唄 } } ], next_key : 304359900245395412, queue : @easemob.com, timestamp : 1488429111530 } }
刪除:
[2017/3/2 12:31:34:502]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 3847, to : @easemob.com, ns : ROSTER, payload : { operation : REMOVE, tos : [ easemob-demo#chatdemoui_lz2 ], reason : , bi_direction : 0 } } } }
[2017/3/2 12:31:34:628]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304359826958321704, timestamp : 1488429094423, ns : ROSTER, payload : { operation : REMOVE, from : easemob-demo#chatdemoui_lz2@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com/mobile ], roster_ver : DB5BEDE0B3C0828FF9C2B7E2C119D30AC8AA66E4 } } ], next_key : 304359826958321704, queue : @easemob.com, timestamp : 1488429094467 } }
同意:
[2017/3/2 12:40:33:251]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304362140305721384, timestamp : 1488429633032, ns : ROSTER, payload : { operation : ACCEPT, from : easemob-demo#chatdemoui_lz2@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com/mobile ], roster_ver : 31A3278F5D16C2726689A176C39D81FF9961647A } } ], next_key : 304362140305721384, queue : @easemob.com, timestamp : 1488429633077 } }
被同意:
[2017/3/2 12:42:59:308]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304362767614216148, timestamp : 1488429779090, ns : ROSTER, payload : { operation : REMOTE_ACCEPT, from : easemob-demo#chatdemoui_lz2@easemob.com/mobile, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], roster_ver : 13B1298E1FAF70683EB467693584B2FD74CBDC6D } } ], next_key : 304362767614216148, queue : @easemob.com, timestamp : 1488429779133 } }
拒絕:
[2017/3/2 12:39:52:931]: log: level: 1, area: 1, SEND:
{ verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, payload : { meta : { id : 4103, to : @easemob.com, ns : ROSTER, payload : { operation : DECLINE, tos : [ easemob-demo#chatdemoui_lz2 ], reason : , bi_direction : 0 } } } }
被拒絕:
[2017/3/2 12:42:59:308]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304362767614216148, timestamp : 1488429779090, ns : ROSTER, payload : { operation : REMOTE_DECLINE, from : easemob-demo#chatdemoui_lz2@easemob.com/mobile, tos : [ easemob-demo#chatdemoui_lz1@easemob.com ], roster_ver : 13B1298E1FAF70683EB467693584B2FD74CBDC6D } } ], next_key : 304362767614216148, queue : @easemob.com, timestamp : 1488429779133 } }
加入黑名單
[2017/3/2 12:43:18:539]: log: level: 1, area: 1, RECV:
{ verison : MSYNC_V1, command : SYNC, payload : { status : { error_code : 0 }, metas : [ { id : 304362850200061992, timestamp : 1488429798324, ns : ROSTER, payload : { operation : BAN, status : { error_code : 0 }, from : easemob-demo#chatdemoui_lz2@easemob.com, tos : [ easemob-demo#chatdemoui_lz1@easemob.com/mobile ] } } ], next_key : 304362850200061992, queue : @easemob.com, timestamp : 1488429798362 } }
通話相關(guān)
由于通話功能大部分都是由底層實(shí)現(xiàn),這邊暫時(shí)無(wú)法看懂,也就先不寫(xiě)了
結(jié)束語(yǔ)
沒(méi)有什么能一眼看出錯(cuò)誤的方法,只要記住正常的日志是什么樣的,以后只要遇到錯(cuò)誤的日志就知道這不正常了,所有能通過(guò)日志看出來(lái)問(wèn)題的問(wèn)題,都不是說(shuō)一下根據(jù)哪一點(diǎn)日志就能知道的,一般都是需要聯(lián)系下上下文的日志,然后結(jié)合場(chǎng)景才好分析
沒(méi)什么投機(jī)取巧的方式,其實(shí)都是熟能生巧,然后大家互相交流,分享自己所知道的
最后希望這一篇分析能對(duì)大家有所幫助,
錯(cuò)誤碼參考:-官方 API 文檔 Error