以下错误是随机的,它是在建立与xmpp服务器的连接时出现的。
1.SASLError使用SCRAM-SHA-1:未经授权
2。在回复超时时间内未收到响应。超时时间为20000毫秒(约20秒)。在等待成功的SASL身份验证时 目前我正在使用smack:4.2.2
我已经尝试过这种方法,但是没有解决方案。
SASLAuthentication.blacklistSASLMechanism("SCRAM-SHA-1)
SASLAuthentication.blacklistSASLMechanism("DIGEST-MD5)
SASLAuthentication.unBlacklistSASLMechanism("PLAIN");
代码:
private class ConnectionTask extends AsyncTask<Void, Void, Exception> {
@Override
protected void onPreExecute() {
super.onPreExecute();
sendConnectionCallbacks(ConnectionStatus.connecting, null);
}
@Override
protected Exception doInBackground(Void... voids) {
LOGGER.log(Level.INFO, "Connecting to XMPP server");
try {
if (!mConnection.isConnected())
mConnection.connect();
if (!mConnection.isAuthenticated()) {
//String authToken =PreferenceHelper.getObj().getUserToken().replace("token ","");
int resourceId = NTUtility.getRandomNumber(10000000, 1);
mConnection.login(mAccount.getmUserName(), mAccount.getmPassword(), Resourcepart.from(String.valueOf(resourceId)));
}
manageAutoDeliveryReceipts();
} catch (XMPPException | SmackException | IOException | InterruptedException e) {
e.printStackTrace();
return e;
}
return null;
}
@Override
protected void onPostExecute(Exception exp) {
super.onPostExecute(exp);
if (exp != null) {
onConnectionClosedOnError(exp);
Log.d("connection", exp.getMessage());
} else {
LOGGER.log(Level.INFO, "Connection task completed successfully");
}
}
}