Hi, it took a while to me, but I was able to figure out this solution. As this thread is still open, I’ll put my working code here in case other people are having the same problem.
I was using version 3.0.0 because of this error… now it works with 3.1.0
The gratest problem (in may case) was that I wasn’t setting my connection properly (SASLAuth MUST be false).
Here is it:
public static void main(String[] args)
{
System.out.println(“Starting…”);
ConnectionConfiguration connCfg = new ConnectionConfiguration(“talk.google.com”, 5222, “gmail.com”);
connCfg.setSASLAuthenticationEnabled(false);
XMPPConnection connection = new XMPPConnection(connCfg);
System.out.println(“Connecting…”);
try
{
connection.connect();
System.out.println("Connected to " + connection.getHost());
}
catch (XMPPException ex)
{
System.out.println("Failed to connect to " + connection.getHost() + ": " + ex.getMessage());
System.exit(1);
}
System.out.println(“Loggin in…”);
try
{
connection.login(“vgartner”, “#$CxFm(6KD”);
// SASLAuthentication.supportSASLMechanism(“PLAIN”,0);
System.out.println("Logged in as " + connection.getUser());
Presence presence = new Presence(Presence.Type.available);
connection.sendPacket(presence);
}
catch (XMPPException ex)
{
System.out.println("Failed to log in as " + connection.getUser() + ": " + ex.getMessage());
System.exit(1);
}
Roster roster = connection.getRoster();
Collection entries = roster.getEntries();
System.out.println("\n\n" + entries.size() + " buddy(ies):");
for (RosterEntry r : entries)
{
System.out.println(r.getUser());
}
connection.disconnect();
}
public static void main(String[] args)
{
System.out.println("Starting...");
ConnectionConfiguration connCfg = new ConnectionConfiguration("talk.google.com", 5222, "gmail.com");
// This should be the problem in most cases I saw.
connCfg.setSASLAuthenticationEnabled(false);
XMPPConnection connection = new XMPPConnection(connCfg);
System.out.println("Connecting...");
try
{
connection.connect();
System.out.println("Connected to " + connection.getHost());
}
catch (XMPPException ex)
{
System.out.println("Failed to connect to " + connection.getHost() + ": " + ex.getMessage());
System.exit(1);
}
System.out.println("Loggin in...");
try
{
connection.login(userName, password);
System.out.println("Logged in as " + connection.getUser());
}
catch (XMPPException ex)
{
System.out.println("Failed to log in as " + connection.getUser() + ": " + ex.getMessage());
System.exit(1);
}
Roster roster = connection.getRoster();
Collection<RosterEntry> entries = roster.getEntries();
System.out.println("\n\n" + entries.size() + " buddies:");
for (RosterEntry r : entries)
{
System.out.println(r.getUser());
}
connection.disconnect();
}
I hope that it helps.
Best regards,
Vilson C. Gärtner