Android XMPP简单聊天:登录错误使用PLAIN机制SASL身份验证失败

时间:2014-12-16 16:20:02

标签: android authentication xmpp chat sasl

标题说我是android的新手。 我正在尝试使用以下代码构建非常简单的聊天。

//1. connection
ConnectionConfiguration connConfig = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
try{ connection.connect();}
catch (XMPPException ex)
{   
 connection = null;
 return;
}

//2. login
try{  connection.login(myGmailLogin,myGmailPwd); }
catch (XMPPException e)
{
  report+="Login error " + e.toString() ;
  return;
}

我得到的是:登录错误使用PLAIN机制SASL身份验证失败。 通过谷歌搜索,我发现有几十页来自有相同问题但没有解决方案的人。 谁能帮帮我吗? 非常感谢!

1 个答案:

答案 0 :(得分:0)

  1. 使用 ConnectionConfiguration connConfig = new ConnectionConfiguration("gmail.com");, 所有其他参数将自动设置
  2. Google不允许在不安全的连接上进行PLAIN身份验证,请确保需要TLS连接:connConfig.setSecurityMode(SecurityMode.required);
相关问题