I'm using Smack to realize my p2p application, but I can't connect to my local openfire server...
If I run this code as a java application I have no problem, but if i run it as Android project my connection is refused...
My simple code:
Using java Syntax Highlighting
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.SASLAuthentication;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
import android.util.Log;
public class GatewayConnection {
public static final String SERVER="localhost";
public static final int PORT=5222;
public static final String TAG="XMPP";
XMPPConnection conn;
public GatewayConnection(){
ConnectionConfiguration config = new ConnectionConfiguration(SERVER,PORT);
config.setCompressionEnabled(false);
config.setSASLAuthenticationEnabled(false);
config.setSecurityMode(ConnectionConfiguration.SecurityMode.disabled);
conn= new XMPPConnection(config);
try{
conn.connect();
}
catch(XMPPException e){
e.printStackTrace();
}
SASLAuthentication.supportSASLMechanism("PLAIN", 0);
try{
conn.login("android", "password");");}
catch (XMPPException e){
e.printStackTrace();
}
}
}
Parsed in 0.034 seconds, using
GeSHi 1.0.8.4
I also include the internet permission in the manifest.
The error occurs after the line conn.connect();
Any suggestion???
Thank you in advance