DeliveryReceiptRequest is not being added to the message

I enable the functionality with

DeliveryReceiptManager.getInstanceFor(connection).autoAddDeliveryReceiptRequests ();

but the receipt request was not being added to the message.

After some debugs, I noticed that the DeliveryReceiptRequest is being added after the message is written in the writer.

I think that’s why it is using addPacketSendingListener. If it would be added with addPacketInterceptor it would work.

public void autoAddDeliveryReceiptRequests() {

    connection().addPacketSendingListener(AUTO_ADD_DELIVERY_RECEIPT_REQUESTS_LISTEN ER,

                    MessageTypeFilter.NORMAL_OR_CHAT_OR_HEADLINE);

}

Another issue is that the receipt request must not be added in messages that contains an ack. So the filter should be increment to see that.

As XEP-0184 says:

5.4 Ack Messages

To prevent looping, an entity MUST NOT include a receipt request (i.e., the element) in an ack message (i.e., a message stanza that includes the element).

Also, I think the ack doesn’t need to have a type

Without havin had a closer look: why do you think it doesn’t work because the sending listener is used?

Actually I tested it.

Take a look where the sending listeners are fired (XMPPTCPConnection:1364)

writer.write(element.toXML().toString()); // the packet is written here

if (queue.isEmpty()) {

writer.flush();

}

if (packet != null) {

firePacketSendingListeners(packet); // the receipt request is added here

}

Just to clarify, I meant to say that I did not look at the code before replying.

Yes, the sending listeners are the wrong type of listeners, as they are meant to inform interested parties when a stanza as been sent. Also the filter should exclude messages with ack requests. Thanks for reporting SMACK-656.

Nice!

Thanks, Flow! The Smack is getting better and better

1 Like