Search code examples
androidbonjoursmackasmack

Xmpp connection using asmack and bonjour on android


I'm trying to do a server-less app for IM. I use apple bonjour protocol to discover xmpp services. But once I get those I can't connect to my host (linux computer using pidgin + bonjour).

Here is my code (taken from here) :

public class Xmpp extends AsyncTask<Void, Void, Void>
{
    @Override
    protected Void doInBackground(Void... arg0)
    {
        ConnectionConfiguration connConfig =
                new ConnectionConfiguration("192.168.0.11", 5298, "bonjour");
        XMPPConnection connection = new XMPPConnection(connConfig);
         try
        {
            // Connect to the server
            connection.connect();
             // Most servers require you to login before performing other tasks.
            connection.login("grea08", "mypass");
            // Start a new conversation with John Doe and send him a message.
            Chat chat = connection.getChatManager().createChat("grea09@192.168.0.11", new MessageListener() {


                 public void processMessage(Chat chat, Message message) {
                     // Print out any messages we get back to standard out.
                     Log.v(getClass().getName(), "Received message: " + message);
                 }
             });

            chat.sendMessage("Howdy!");
        } catch (XMPPException e)
        {
            // TODO Auto-generated catch block
            Log.e(getClass().getName(), "Xmpp error !", e);
        }
         // Disconnect from the server
         connection.disconnect();
        return null;
    }

}

I've got an XmppException "No response from server". I think that the host is not an XMPP server and we must use the protocol this way.


Solution

  • Smack and aSmack has no support for XEP-0174 (aka. link-local or serverless messaging). Jonas patches never made it into the trunk. The corresponding issue to track is SMACK-262.