Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7007465
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:36:38+00:00 2026-05-27T21:36:38+00:00

I’ve successfully connected to XMPP server (from android XMPP client), and I can send

  • 0

I’ve successfully connected to XMPP server (from android XMPP client), and I can send messages to a user, but I can’t receive responses from that same user.

I’m sending messages like this:

  public void send_message(String message, String buddy) throws XMPPException {
    buddy += "@localhost";

    /* send message to user */
    Log.w("Sending mesage " + message + " to user " + buddy, "0");
    chat = chatManager.createChat(buddy, messageListener);
    chat.sendMessage(message);
  }

I’m passing the messageListener to the createChat function. The MessageListener’s class is:

class XMPPMessageListener implements MessageListener {
  private String from;
  private String body;

  public void processMessage(Chat chat, Message message) {
    this.from = message.getFrom();
    this.body = message.getBody();
    Log.w("*****Received message" + body + " from " + from, "0*****");
  }

}

When sending a message to a user I’m getting the following debugging output:

W/Sending mesage play to user test@localhost(  823): 0
D/SMACK   (  823): 10:43:54 AM SENT (1156346368): <message id="vwaJX-15" to="test@localhost" from="eleano@localhost/Smack" type="chat"><body>test</body><thread>249ke0</thread></message>
D/SMACK   (  823): 10:43:54 AM RCV  (1156346368): <presence id="vwaJX-12" to="eleano@localhost/Smack" from="eleano" type="error"><error code="404" type="cancel"><remote-server-no
D/SMACK   (  823): 10:43:54 AM RCV  (1156346368): t-found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></presence>
D/SMACK   (  823): 10:43:54 AM RCV  (1156346368): <presence id="vwaJX-14" to="eleano@localhost/Smack" from="test" type="error"><error code="404" type="cancel"><remote-server-not-
D/SMACK   (  823): 10:43:54 AM RCV  (1156346368): found xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error></presence>

And the message “test” is displayed to the connected user test (in this case). I’m sending the message from a user eleano. We can also see there’s a debug output “ending mesage play to user test@localhost” being displayed on the screen, indicating that my function is indeed called successfully.

Upon receiving the message from test to eleano, I only get this debug output:

D/SMACK   (  823): 10:44:00 AM RCV  (1156346368): <message id="58Fjj-64" to="eleano@localhost/Smack" from="test@localhost/Spark 2.6.3" type="chat"><body>yes</body><thread>0tlK7o<
D/SMACK   (  823): 10:44:00 AM RCV  (1156346368): /thread><x xmlns="jabber:x:event"><offline/><composing/></x></message>

But the user eleano is not receiving the message. We can also notice there’s no:

Log.w("*****Received message" + body + " from " + from, "0*****");

being displayed on the screen, so the MessageListener is never called. Why is that? I’ve set it up correctly as it says in documentation.

Any ideas are welcome. And thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T21:36:38+00:00Added an answer on May 27, 2026 at 9:36 pm

    Thanks for pointing that out. Your observation led me to setup a listener on connection (and to listen for packages of type Char), rather than setting a listener on the chat object itself.

    Now my code looks like the following. I’m sending the packages like this:

    Message m = new Message(buddy, Message.Type.chat);
    m.setBody(message);
    connection.sendPacket(m);
    

    And receiving the messages like the following:

      /* packet listener: listen for incoming messages of type CHAT on the connection (whatever the buddy) */
      PacketFilter filter = new MessageTypeFilter(Message.Type.chat); 
      xmppManager.connection.addPacketListener(new PacketListener() { 
        public void processPacket(Packet packet) {
          Message mes = (Message)packet;
          Log.w("***"+mes.toString()+"***","0");
        }
      }, filter);
    

    And it works. I can send messages to the user and receive them just fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to clean up various Word 'smart' characters in user input, including but
Does anyone know how can I replace this 2 symbol below from the string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a jquery bug and I've been looking for hours now, I can't
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.