Quantcast
Channel: Ignite Realtime : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 10742

trouble connecting aSmack with Openfire. (using Andriod)

$
0
0

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 <uses-permission android:name="android.permission.INTERNET" />  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();

                       }

}


Viewing all articles
Browse latest Browse all 10742

Trending Articles