注册

android项目接入环信IM通讯模块,用户二次登陆时输入错误密码也能登陆的问题

因公司Android项目需要即时单对单通信模块,经挑选后觉着环信IM模块非常符合我们的需求,故将环信IM通讯模块增加到项目中,但在后期开发过程中发现一个问题,一直没有找到解决的办法,特请教各位大佬,望指教,现将问题描述如下:
在项目中切换到环信IM登陆窗口,如果输入错误的账号和密码则弹“username or password is wrong”错误的提示框,在输入正确的账户和密码后正常进入环信聊天单对单聊天框,聊天完毕后,退出聊天模块进入到公司项目模块,后再次切换到环信IM登陆窗口,此时输入上次的账号和错误的密码,点击登陆按钮,则能登陆到环信聊天,看了后台Log输出后,发现SDK中输出有fetchToken()验证,后又收到 fetchTokenForUser return code : 400  response : {"error":"invalid_grant","timestamp":1613627551579,"duration":0,"error_description":"invalid password"}消息,同时在EMClient.getInstance().login(usrName, password, new EMCallBack()) 函数执行后,则转入到 onSuccess() 中,登陆成功?!,请问下fetchToken()是在何处触发的,同时如何抓取到该token验证的错误信息,以便能打断错误登陆,做到避免用户在二次登陆时输入错误的密码也能登陆到环信IM聊天室的错误,谢谢!
 
环信SDK版本:3.6.2
 
已邀请:
以下是部分Log信息:

D/ViewRootImpl@b87bea4[LoginActivity]: ViewPostIme pointer 0
D/ViewRootImpl@b87bea4[LoginActivity]: ViewPostIme pointer 1
D/>>>?LoginActivity: signin() ... enter ...
D/signOut:  ... enter ... 
    isSignIn is false ... 
D/>>>?LoginActivity: show dialog now ...
D/Dialog: mIsSamsungBasicInteraction = false
    mIsSamsungBasicInteraction = false, isMetaDataInActivity = false
I/MultiWindowDecorSupport: updateCaptionType >> DecorView@3856770[], isFloating: true, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: false
D/MultiWindowDecorSupport: setCaptionType = 0, DecorView = DecorView@3856770[]
D/ScrollView: initGoToTop
D/ViewRootImpl@1a14ff[LoginActivity]: setView = com.android.internal.policy.DecorView@3856770 TM=true MM=false
D/>>>?LoginActivity: check userName and password ...
    search dest user ...
    login() now ...
D/ONE?SDK: [2021/02/19 14:13:26:650]: EMDatabase::open 
D/ONE?SDK: [2021/02/19 14:13:26:651]: sqlite version: 3.26.0
    [2021/02/19 14:13:26:651]: EMDatabase::getDBVersion: 6
    [2021/02/19 14:13:26:651]: EMDatabase::getDBVersion: 6
    [2021/02/19 14:13:26:651]: performMigrationIfNecessary current DB version: 6
    [2021/02/19 14:13:26:651]: EMSessionManager::login(): is autoLogin? 0, id: u1
    [2021/02/19 14:13:26:651]: getDnsListFromServer()
    [2021/02/19 14:13:26:651]: buildUrl(): use default address
    [2021/02/19 14:13:26:651]: buildUrl(): http://rs.easemob.com/easemob/server.json?sdk_version=3.6.2&app_key=1109191121098997%23hexagon&file_version=1429
    [2021/02/19 14:13:26:651]: httprequest perform: http://rs.easemob.com/easemob/server.json?sdk_version=3.6.2&app_key=1109191121098997%23hexagon&file_version=1429
I/System.out: Thread-10664(ApacheHTTPLog):isSBSettingEnabled false
    Thread-10664(ApacheHTTPLog):isShipBuild true
    Thread-10664(ApacheHTTPLog):getDebugLevel 0x4f4c
    Thread-10664(ApacheHTTPLog):Smart Bonding Setting is false
    Thread-10664(ApacheHTTPLog):SmartBonding Setting is false, SHIP_BUILD is true, log to file is false, DBG is false, DEBUG_LEVEL (1-LOW, 2-MID, 3-HIGH) is 1
D/ViewRootImpl@1a14ff[LoginActivity]: Relayout returned: old=(0,72,1080,2076) new=(0,930,1080,1218) req=(1080,288)0 dur=7 res=0x7 s={true 513639620608} ch=true
D/OpenGLRenderer: createReliableSurface : 0x779d59fdc0(0x77974ea000)
I/mali_winsys: new_window_surface() [1092x300] return: 0x3000
I/DefaultRequestDirector: I/O exception (java.io.IOException) caught when processing request: Cleartext traffic not permitted: http://rs.easemob.com
E/DecorView: mWindow.mActivityCurrentConfig is null
I/DefaultRequestDirector: Retrying request
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/ViewRootImpl@1a14ff[LoginActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
I/DefaultRequestDirector: I/O exception (java.io.IOException) caught when processing request: Cleartext traffic not permitted: http://rs.easemob.com
    Retrying request
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/ViewRootImpl@1a14ff[LoginActivity]: MSG_RESIZED: frame=(0,930,1080,1218) ci=(0,0,0,0) vi=(0,0,0,0) or=1
D/ViewRootImpl@b87bea4[LoginActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@b7622e5[LoginActivity]
    getNavigationBarColor() -855310
I/DefaultRequestDirector: I/O exception (java.io.IOException) caught when processing request: Cleartext traffic not permitted: http://rs.easemob.com
    Retrying request
I/System.out: pool-4-thread-9 calls detatch()
D/ONE?SDK: [2021/02/19 14:13:26:727]: 2 time retry
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/ONE?SDK: [2021/02/19 14:13:26:728]: getDnsListFromServer code: 408 response: 
    [2021/02/19 14:13:26:728]: buildUrl(): use default ip address
D/ONE?SDK: [2021/02/19 14:13:26:728]: buildUrl(): http://60.205.13.54/easemob/server.json?sdk_version=3.6.2&app_key=1109191121098997%23hexagon&file_version=1429
    [2021/02/19 14:13:26:728]: LoadDNSConfig()
    [2021/02/19 14:13:26:728]: EMDNSManager::parseDnsServer: 
    [2021/02/19 14:13:26:728]: getDnsListFromTCPServer()
D/ONE?SDK: [2021/02/19 14:13:26:728]: EMDNSManager::getCurrentHost: type: 1
    [2021/02/19 14:13:26:728]: EMDNSManager::getHost: type: 1
    [2021/02/19 14:13:26:728]: getDnsListFromTCPServer(): addr: 59.110.89.59
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/ONE?SDK: [2021/02/19 14:13:26:752]: EMDNSManager::getNextAvailableHost: type: 1
    [2021/02/19 14:13:26:752]: getDnsListFromTCPServer(): addr: 59.110.89.59
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/ONE?SDK: [2021/02/19 14:13:26:772]: DNS List size: 2663
    [2021/02/19 14:13:26:772]: EMDNSManager::parseDnsServer: {"file_version":"1429","resolver":{"hosts":[{"port":"80","domain":"rs.easemob.com","ip":"39.97.193.187"},{"protocol":"https","port":"443","domain":"rs4.easemob.com"},{"port":"80","domain":"rs.easemob.com","ip":"39.97.193.190"},{"protocol":"https","port":"443","domain":"rs1.easemob.com"},{"protocol":"https","port":"443","domain":"rs2.easemob.com"},{"port":"80","domain":"rs.easemob.com","ip":"59.110.89.59"},{"protocol":"https","port":"443","domain":"rs.easemob.com"},{"protocol":"https","port":"443","domain":"rs3.easemob.com"}]},"rest":{"hosts":[{"protocol":"https","port":"443","domain":"a5-v2.easemob.com"},{"protocol":"http","port":"80","domain":"a1-v2.easemob.com"},{"protocol":"https","port":"443","domain":"a4.easemob.com"},{"protocol":"https","port":"443","domain":"a4-v2.easemob.com"},{"protocol":"http","port":"80","domain":"a1-v2.easemob.com","ip":"47.95.246.247"},{"protocol":"https","port":"443","domain":"a1.easemob.com"},{"protocol":"https","port":"
    [2021/02/19 14:13:26:772]: got dns from tcp server, dns maybe hijacked
    [2021/02/19 14:13:26:772]: ranomOffer
D/ONE?SDK: [2021/02/19 14:13:26:773]: current time: 1613715206773
    [2021/02/19 14:13:26:773]: valid time: 1613974406773
    [2021/02/19 14:13:26:773]: saveConfigs()
    [2021/02/19 14:13:26:773]: write to config file: {
        "dns_time":"1613974406773"
    }
    [2021/02/19 14:13:26:773]: EMDNSManager::getCurrentHost: type: 2
    [2021/02/19 14:13:26:773]: EMSessionManager::checkDNS()
    [2021/02/19 14:13:26:773]: EMDNSManager::getHost: type: 2
    [2021/02/19 14:13:26:773]: current host: domain: 39.97.193.172 port: 12019
D/ONE?SDK: [2021/02/19 14:13:26:773]: setServer: 39.97.193.172
    [2021/02/19 14:13:26:773]: Calling connect...
    [2021/02/19 14:13:26:774]: doConnect()
    [2021/02/19 14:13:26:774]: current connectState: 0
    [2021/02/19 14:13:26:774]: log: level: 2, area: 1, ChatClient::connect() 
    [2021/02/19 14:13:26:774]: log: level: 0, area: 2, getSocket(): 117
D/ONE?SDK: [2021/02/19 14:13:26:774]: log: level: 1, area: 2, connectSocket(): start to connecting...
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/ONE?SDK: [2021/02/19 14:13:26:781]: log: level: 1, area: 2, connectSocket(): connect finished
D/ONE?SDK: [2021/02/19 14:13:26:781]: log: level: 2, area: 2, connectSocket() OK: fd: 117 Client:192.168.0.10:49540 Server: 39.97.193.172:12019
    [2021/02/19 14:13:26:781]: log: level: 0, area: 1, SEND:
    { verison : MSYNC_V1, guid : 1109191121098997#hexagon_u1@easemob.com/android_3dc6e3a3-ae1d-3cf2-a4c5-430a35b474d1, auth : ***, compress_algorimth : 0, command : PROVISION, encrypt_type : [ 0 ], payload : { os_type : 1, version : 3.6.2, compress_type : [ COMPRESS_NONE ], device_uuid : 3dc6e3a3-ae1d-3cf2-a4c5-430a35b474d1, is_manual_login : true, device_name : samsungSM-G960N, resource : android_3dc6e3a3-ae1d-3cf2-a4c5-430a35b474d1, password : ***, auth : *** } }
    [2021/02/19 14:13:26:781]: Calling connect result: 1
    [2021/02/19 14:13:26:782]: start startReceive()
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/ONE?SDK: [2021/02/19 14:13:26:794]: log: level: 0, area: 1, RECV:
    { verison : MSYNC_V1, command : PROVISION, payload : { compress_type : [ COMPRESS_NONE ], status : { error_code : 0 }, resource : android_3dc6e3a3-ae1d-3cf2-a4c5-430a35b474d1 } }
    [2021/02/19 14:13:26:794]: EMSessionManager::onConnect()
    [2021/02/19 14:13:26:794]: log: level: 2, area: 1, SEND:
    { verison : MSYNC_V1, compress_algorimth : 0, command : UNREAD, encrypt_type : [ 0 ], payload : {  } }
    [2021/02/19 14:13:26:794]: [im login time] 0: 0: 20
D/ONE?SDK: [2021/02/19 14:13:26:794]: login return: 0
    [2021/02/19 14:13:26:794]: [chat login time] 0: 0:144
    [2021/02/19 14:13:26:794]: notify state change to connection listener
    [2021/02/19 14:13:26:795]: EMConnectionListener onConnected
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/ONE?SDK: [2021/02/19 14:13:26:805]: log: level: 0, area: 1, RECV:
    { verison : MSYNC_V1, command : UNREAD, payload : { status : { error_code : 0 }, timestamp : 1613715208912 } }
D/ONE?SDK: [2021/02/19 14:13:26:805]: log: level: 1, area: 1, NO unread queue, an response for ping?
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/ONE?SDK: [2021/02/19 14:13:26:856]: log: level: 0, area: 1, sendPing
    [2021/02/19 14:13:26:856]: log: level: 0, area: 1, SEND:
    { verison : MSYNC_V1, compress_algorimth : 0, command : UNREAD, encrypt_type : [ 0 ], payload : {  } }
D/ONE?SDK: [2021/02/19 14:13:26:863]: log: level: 0, area: 1, RECV:
    { verison : MSYNC_V1, command : UNREAD, payload : { status : { error_code : 0 }, timestamp : 1613715208972 } }
    [2021/02/19 14:13:26:863]: log: level: 1, area: 1, NO unread queue, an response for ping?
    [2021/02/19 14:13:26:863]: native_1sendPing
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
W/JobInfo: Requested interval +1m0s0ms for job 11 is too small; raising to +15m0s0ms
    Requested flex +1m0s0ms for job 11 is too small; raising to +5m0s0ms
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780

---------------------------- 此处开始验证 ----------------------------

D/ONE?SDK: [2021/02/19 14:13:26:868]: fetchToken()
    [2021/02/19 14:13:26:868]: restBaseUrl()
    [2021/02/19 14:13:26:868]: EMDNSManager::getCurrentHost: type: 3
D/ONE?SDK: [2021/02/19 14:13:26:868]: EMSessionManager::checkDNS()
    [2021/02/19 14:13:26:868]: EMDNSManager::getHost: type: 3
    [2021/02/19 14:13:26:868]: current host: domain: 39.97.9.52 port: 80
    [2021/02/19 14:13:26:868]: fetchTokenForUser()http://39.97.9.52:80/1109191121098997/hexagon/token
    [2021/02/19 14:13:26:868]: httprequest perform: http://39.97.9.52:80/1109191121098997/hexagon/token
I/System.out: Thread-10664(ApacheHTTPLog):isSBSettingEnabled false
    Thread-10664(ApacheHTTPLog):isShipBuild true
    Thread-10664(ApacheHTTPLog):getDebugLevel 0x4f4c
    Thread-10664(ApacheHTTPLog):Smart Bonding Setting is false
I/System.out: Thread-10664(ApacheHTTPLog):SmartBonding Setting is false, SHIP_BUILD is true, log to file is false, DBG is false, DEBUG_LEVEL (1-LOW, 2-MID, 3-HIGH) is 1
I/DefaultRequestDirector: I/O exception (java.io.IOException) caught when processing request: Cleartext traffic not permitted: http://39.97.9.52:80
    Retrying request
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
I/DefaultRequestDirector: I/O exception (java.io.IOException) caught when processing request: Cleartext traffic not permitted: http://39.97.9.52:80
I/DefaultRequestDirector: Retrying request
I/DefaultRequestDirector: I/O exception (java.io.IOException) caught when processing request: Cleartext traffic not permitted: http://39.97.9.52:80
    Retrying request
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
I/System.out: pool-4-thread-9 calls detatch()
W/System.err: java.io.IOException: Cleartext traffic not permitted: http://39.97.9.52:80
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780
D/ONE?SDK: [2021/02/19 14:13:26:901]: fetchTokenForUser return code : 408  response :  and error desc: 
    [2021/02/19 14:13:26:901]: restBaseUrl()
    [2021/02/19 14:13:26:901]: EMDNSManager::getNextAvailableHost: type: 3
    [2021/02/19 14:13:26:901]: EMSessionManager::checkDNS()
    [2021/02/19 14:13:26:901]: EMDNSManager::getNextAvailableHost: new index: 1
    [2021/02/19 14:13:26:901]: EMDNSManager::getHost: type: 3
D/ONE?SDK: [2021/02/19 14:13:26:901]: current host: domain: a1.easemob.com port: 443
I/System.out: Thread-10664(ApacheHTTPLog):isSBSettingEnabled false
D/ONE?SDK: [2021/02/19 14:13:26:901]: httprequest perform: https://a1.easemob.com:443/1109191121098997/hexagon/token
I/System.out: Thread-10664(ApacheHTTPLog):isShipBuild true
    Thread-10664(ApacheHTTPLog):getDebugLevel 0x4f4c
    Thread-10664(ApacheHTTPLog):Smart Bonding Setting is false
    Thread-10664(ApacheHTTPLog):SmartBonding Setting is false, SHIP_BUILD is true, log to file is false, DBG is false, DEBUG_LEVEL (1-LOW, 2-MID, 3-HIGH) is 1
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x7797f15080
I/System.out: pool-4-thread-9 calls detatch()
D/OpenGLRenderer: makeCurrent EglSurface : 0x7797f15080 -> 0x779785f780

---------------------------- 此处收到错误返回 ----------------------------

D/ONE?SDK: [2021/02/19 14:13:26:950]: fetchTokenForUser return code : 400  response : {"error":"invalid_grant","timestamp":1613715209059,"duration":0,"error_description":"invalid password"} and error desc: 

---------------------------- 此处收到登陆成功 ----------------------------

D/>>>?LoginActivity: login() -> onSuccess() ... enter ...
D/ONE?SDK: [2021/02/19 14:13:26:950]: [retrieve token time] 0: 0: 82
D/ONE?SDK: [2021/02/19 14:13:26:950]: fetchToken can't fetch user token: 202
D/OpenGLRenderer: makeCurrent EglSurface : 0x779785f780 -> 0x0
    destroyEglSurface : 0x779785f780
I/mali_egl: eglDestroySurface() in
I/mali_winsys: delete_surface() [1092x300] return
I/mali_egl: eglDestroySurface() out
W/libEGL: EGLNativeWindowType 0x779d59fdd0 disconnect failed
D/OpenGLRenderer: ~ReliableSurface : 0x779d59fdc0
D/ViewRootImpl@1a14ff[LoginActivity]: dispatchDetachedFromWindow
D/InputTransport: Input channel destroyed: 'f319a2e', fd=114
D/ViewRootImpl@b87bea4[LoginActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@b7622e5[LoginActivity]
    getNavigationBarColor() -855310
D/ONE?SDK: [2021/02/19 14:13:27:000]: log: level: 0, area: 1, SEND:
    { verison : MSYNC_V1, compress_algorimth : 0, command : SYNC, encrypt_type : [ 0 ], payload : { meta : { id : 591, ns : STATISTIC, payload : { operation : 0, im_time : 20, chat_time : 144 } } } }
E/ViewRootImpl: sendUserActionEvent() mView returned.
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@41335c

要回复问题请先登录注册