0
votes

I am new to implementing XMPP and working on Android XMPP client using SMACK v4.0.6. I am trying to connect to a SMACK server running on my local Linux machine using the following code

`ConnectionConfiguration connConfig = new ConnectionConfiguration(localServerIP, 5222);
XMPPConnection connection = new XMPPConnection(connConfig);
try{
    connection.connect();
}catch(Exception e)`.

I am unable to connect to the server and I only get a ConnectionException. Both the client and server are connected to the same local network and Android application has permission to connect with Internet. The server is running the default configuration. Could you please tell what I am missing?

Thanks

1

1 Answers

0
votes

Update smack to 4.1. In your gradle, add

compile 'org.igniterealtime.smack:smack-android:4.1.0'
compile 'org.igniterealtime.smack:smack-tcp:4.1.0'
compile 'org.igniterealtime.smack:smack-android-extensions:4.1.0'

Please try this one.

XMPPTCPConnectionConfiguration.Builder configBuilder = XMPPTCPConnectionConfiguration.builder();
    configBuilder.setHost(url);
    configBuilder.setPort(port);
    configBuilder.setServiceName("your service name");
    configBuilder.setSendPresence(true);

    try{
                connection = new XMPPTCPConnection(configBuilder.build());
                // Connect to the server
                connection.connect();
    }catch (XMPPException | SmackException | IOException e ) {
                e.printStackTrace();
    }