AnsweredAssumed Answered

XMPP BOSH clients don't receive each other's messages.

Question asked by Simone on Nov 16, 2015

Hello,

I started today learning about XMPP BOSH and the Smack API.

 

I tried to create two simple client running at localhost:

 

  • client1: acting as a sender and having the name sender;
  • client2: acting as a receiver and having the name receiver;

 

The are both connected to a remote server with a given server_ip (e.g. 10.10.10.10) and server_port (7070).

 

Both clients use:

 

  • BOSHConfiguration and XMPPBOSHConnection;
  • Their StanzaListener and StanzaListener simple implementation for tracing incoming stanzas;
  • They use smack-core and smack-bosh 4.1.4 as maven dependecies.

 

The sender:

 

  • Successfully connects to the server;
  • Sends the message to receiver@10.10.10.10.
  • I perfectly monitor the packets sent by client1 to the server;
  • I saw a 401 error for each message:
    • <error code="401" type="auth"><not-authorized xmlns="urn:ietf:params:xml:ns:xmpp-stanzas"/></error>

 

The receiver:

  • Doesn't receive nothing at all.

 

 

 

A snippet:

 

BOSHConfiguration boshConfiguration = BOSHConfiguration.builder().setUsernameAndPassword(properties.getProperty("send er"), properties.getProperty("password"))

  .setFile(HTTP_BIND)

  .setHost(properties.getProperty("server_host"))

  .setPort(Integer.valueOf(properties.getProperty("server_port")))

  .setServiceName(properties.getProperty("service_name"))

  .setDebuggerEnabled(true)

  .setSendPresence(true)

  .build();

 

 

  XMPPBOSHConnection boshConnection = new XMPPBOSHConnection(boshConfiguration);

 

 

  try {

  boshConnection.connect();

  boshConnection.addAsyncStanzaListener(new StanzaListener() {

 

  @Override

  public void processPacket(Stanza stanza) throws NotConnectedException {

  logger.info("New stanza received {}.", stanza);

  }

  }, new StanzaFilter() {

 

  @Override

  public boolean accept(Stanza stanza) {

  logger.info("Filtering new stanza {}.", stanza);

  return stanza.getTo().contains("sender");

  }

  });

 

Message message = new Message("receiver@10.10.10.10");

boshConnection.sendStanza(message);

 

} catch(....){

...

Outcomes