powered by Jive Software

Trouble connecting aSmack with Openfire. (using Andriod)

Hi, I’ve been trying to make a simple connection to Openfire so that I can see the green user in the conection status. So far I’ve only failed. I’m using Openfire with an embedded database and default configuration, only created the user “chatter”. I’ve read the documentation quite a few times already and I’m not sure if im missing something becasue I’m new at Andriod. Im using asmack-android-8-4.0.0 and dnsjava-2.1.6 in my libraris. Also did not forget in Manisfest.xml. This is my code so far, pretty simple and not working. Any idea? Maybe a configuration in Openfire?

In MainActivity.java a button responds to the following…

public void connect(View v){

//Initialize Smack on Andriod

Context context = getApplicationContext();

SmackAndroid.init(context);

// Create a connection

ConnectionConfiguration connConfig =new ConnectionConfiguration(“10.0.0.4”, 5222, “10.0.0.4”); //not sure what goes on service

XMPPConnection connection = new XMPPTCPConnection(connConfig);

try {

connection.connect();

} catch (SmackException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

try {

//login

connection.login(“chatter”, “mypass”);

// Set the status to available

Presence presence = new Presence(Presence.Type.available);

connection.sendPacket(presence);

} catch (SaslException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (XMPPException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (SmackException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {

// TODO Auto-generated catch block

e.printStackTrace();

}

}

I finally could get the connection and login. The solution using differents aSmack version till i got one that worked for me! Im using asmack-android-19-0.8.10 for those of you who want to try it out.

same thing happens to me,but why asmack 4.0.0 not working?confusing~~~~

hey,guy, I try to use asmack 4.0.0,and succed finally. My suggestion to U as follow:

  1. connect operation can’t be in UIThread,put it in the sub thread,in latest android version,google forbid

time consuming operation in UI Thread;

2.config.setSecurityMode(SecurityMode.disabled),do this before U connect to server,;

3.if Ur server is in local area network,make sure that U close the window firewall,or connection may be refused~

hope that can help U,goodluck~