连接到XMPP服务器时SASL授权失败

SPB*_*SPB 4 xmpp google-talk smack

我正在尝试通过XMPP服务器使用SMACK API连接到gmail.但得到了

错误:使用PLAIN机制的SASL身份验证失败

你可以查看代码的一瞥.我只是从网上得到它

ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
connection = new XMPPConnection(connConfig);
connection.connect();
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
Run Code Online (Sandbox Code Playgroud)

我检查了smack调试窗口.它用XML说:

<invalid-authzid />

我已经在gmail上有帐号,我的gtalk也在运行.

Chu*_*Lee 9

您需要在连接viz之前设置身份验证

SASLAuthentication.supportSASLMechanism("PLAIN", 0);

必须出现在之前connection.connect().

看我的博客.

  • 从2013年11月28日起,我没有为我工作. (5认同)