Quantcast
Channel: Ignite Realtime: Message List
Viewing all articles
Browse latest Browse all 12000

Smack 4.1 beta 1 connection issue

$
0
0

Have been trying to login to my xmpp account using smack in an Android application but i keep getting this same error:

The following addresses failed: gmail.com:5222 Exception: null

 

This is my code

XMPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()

        .setServiceName("gmail.com")

        .setUsernameAndPassword("user", "pwd")

        .setCompressionEnabled(false).build();

XMPPTCPConnection connection = new XMPPTCPConnection(config);

connection.connect();

connection.login();

 

The connect() method throws the exception above.

 

I also tried the following but still same error

MPPTCPConnectionConfiguration config = XMPPTCPConnectionConfiguration.builder()

        .setServiceName("jabber.blah.im")

        .setUsernameAndPassword("user", "pwd")

        .setCompressionEnabled(false).build();

 

I found Flow's presentation PDF yesterday and tried this code below - still the same error! http://geekplace.eu/files/xmpp_and_android.pdf

    public void connectGoogle() throws IOException, XMPPException, SmackException

    {

        XMPPTCPConnection connection = new XMPPTCPConnection("myemail@gmail.com", "pwd", "mtalk.google.com");

        connection.connect();

        connection.login();

    }

 

Manifest file

This is what my manifest looks like! I have permission for internet usage outside of <application> section.

    ...

    <uses-permission android:name="android.permission.INTERNET"/>

    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

 

    <application

        ...

To verify I'm connected to Internet, I'm using this method below and it says I'm connected.

    private boolean isConnected()

    {

        ConnectivityManager connMgr = (ConnectivityManager)getSystemService(Context.CONNECTIVITY_SERVICE);

        NetworkInfo networkInfo = connMgr.getActiveNetworkInfo();

        if (networkInfo != null && networkInfo.isConnected()) {

            return true;

        } else {

            return false;

        }

    }

 

But when I try to use code to connect to XMPP server, exception is throw.   

Anyone knows what I'm missing?

Thanks


Viewing all articles
Browse latest Browse all 12000

Trending Articles