Stream:error (text)

Hi, i’m quiet new in Smack, and i need some help to start.

import org.jivesoftware.smack.*;

public class Client {

private String user;
private String pass;
private String host;
private int port;

private ConnectionConfiguration config;
private XMPPConnection connection;

public Client(String user, String pass, String host, int port){

    this.user = user;
    this.pass = pass;
    this.host = host;
    this.port = port;
   
}

public void login(){
   
    this.config = new ConnectionConfiguration(this.host, this.port);
    this.connection = new XMPPConnection(this.config);
   
    try {
        this.connection.connect();
        this.connection.login(this.user, this.pass);
    } catch (XMPPException e) {
        e.printStackTrace();
    }
   
}

public void diconnect(){
    this.connection.disconnect();
}

}

public class Main {

public static void main(String [ ] args){
   
    Client cl1 = new Client("account@googlemail.com",
                            "pasword",
                            "talk.google.com",
                            5222);
   
    cl1.login();
   
}

}

So when i try to login:

stream:error (text)
at org.jivesoftware.smack.PacketReader.parsePackets(PacketReader.java:306)
at org.jivesoftware.smack.PacketReader.access$000(PacketReader.java:44)
at org.jivesoftware.smack.PacketReader$1.run(PacketReader.java:76)

Whats wrong?

I have the identical problem… smack 3.1.0

I suppose your problem is, that the XMPP domain (or service name) differs from the hostname. So you should use

this.config = new ConnectionConfiguration("talk.google.com", 5222, "googlemail.com");

instead of

this.config = new ConnectionConfiguration("talk.google.com", 5222);

Thanks Guenther,

That helped, and for anyone doing this see http://www.igniterealtime.org/community/thread/35976 , and the updated example:

**Working example
**
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;

public class Client {

private String user;
private String domain;
private String pass;
private String host;
private int port;

private ConnectionConfiguration config;
private XMPPConnection connection;

/** args[0] = user@gmail.com , args[1] = pass */
public static void main(String[] args)
{
  Client cl1 = new Client(args[0], args[1], "talk.google.com", 5222);         
  cl1.login();
}

public Client(String user, String pass, String host, int port){
    this.user = user;
    this.pass = pass;
    this.host = host;
    this.port = port;
    String[] domainSplit=user.split("@");
    this.domain=domainSplit[1];      
}

public void login(){
  
    this.config = new ConnectionConfiguration(this.host, this.port, this.domain);
    this.connection = new XMPPConnection(this.config);
  
    try {           
        this.connection.connect();
        this.connection.login(this.user, this.pass);           
        System.out.println("Is connected: "+this.connection.isConnected());
        System.out.println("Is authenticated: "+this.connection.isAuthenticated());
    } catch (XMPPException e) {
        e.printStackTrace();
    }      
}

public void diconnect(){
    this.connection.disconnect();
}

}