onReceiptReceived not been handled for delivery receipts

Openfire 3.10.3

smack 4.1.6

I am trying to use DeliveryReceipts so that I know that the message has been sent. However, onReceiptReceived is never called.

I have done the following:

DeliveryReceiptManager deliveryReceiptManager = DeliveryReceiptManager.getInstanceFor(mClientConnection);
deliveryReceiptManager.autoAddDeliveryReceiptRequests();

Sending the message

ChatManager chatManager = ChatManager.getInstanceFor(mClientConnection);
Message msg = new Message(username, Message.Type.chat);
msg.setBody(message);
final String msgReceipt = DeliveryReceiptRequest.addTo(msg);
log.log(Level.INFO, "msgReceiptRequest: " + msgReceipt);        Chat chat = chatManager.createChat(username, mChatMessageListener);
chat.sendMessage(message);

Sent message from the client

SENT (0): <message to='97.steve@xmpp1.call-genie.com' id='6xS4w-43' type='chat'><body>hello</body><thread>32091ad3-8da9-4758-9656-c06eb72532a2</thread><request xmlns='urn:xmpp:receipts'/></message>

On the receiving end of the client

<message to='97.steve@xmpp1.call-genie.com' id='6xS4w-43' type='chat'><body>hello</body><thread>32091ad3-8da9-4758-9656-c06eb72532a2</thread><request xmlns='urn:xmpp:receipts'/></message>

This code never gets called

deliveryReceiptManager.addReceiptReceivedListener(new ReceiptReceivedListener() {
    @Override
    public void onReceiptReceived(String fromJid, String toJid, String receiptId, Stanza receipt) {
            log.log(Level.INFO, "OnReceiptReceived fromJid: " + fromJid + " toJid: " + toJid + " receiptId: " + receiptId);
        }
    });
}

I have tried to do something like this when the client receives the message which I was thinking to send back which might trigger the onReceiptReceived event

chat.addMessageListener(new ChatMessageListener() {
    @Override
    public void processMessage(Chat chat, Message msg) {
        if(!msg.getBody().isEmpty()) {
            Message ms = new Message();
            ms.addBody("EN", "delivered");
            ms.setTo(msg.getFrom());
            ms.setStanzaId(msg.getStanzaId());
            DeliveryReceiptRequest.addTo(ms);
            mClientConnection.sendStanza(ms);
        }
        log.log(Level.INFO, "receiveChatMessages Received prompted message: " + msg.getBody());                                    }
}

Many thanks for any suggestions,

If the other side has an enabled DeliveryReceiptManger, then the receipts will be send if the requestor has a valid presence subscription

“If the other side has an enabled DeliveryReceiptManger”

I have done like this which runs on both clients, I hope this is what you met.

DeliveryReceiptManager deliveryReceiptManager = DeliveryReceiptManager.getInstanceFor(mClientConnection);
        deliveryReceiptManager.autoAddDeliveryReceiptRequests();
        DeliveryReceiptManager.setDefaultAutoReceiptMode(DeliveryReceiptManager.AutoReceiptMode.always);
               deliveryReceiptManager.addReceiptReceivedListener(new ReceiptReceivedListener() {
            @Override
            public void onReceiptReceived(String fromJid, String toJid, String receiptId, Stanza receipt) {
                log.log(Level.INFO, "OnReceiptReceived fromJid: " + fromJid + " toJid: " + toJid + " receiptId: " + receiptId);
            }
        });

“if the requestor has a valid presence subscription”

Not sure what you mean, but do you mean setting the presence to subscribed?

Presence(Presence.Type.subscribed);

Here is the debug, as you can see the presence has been set.

<presence id='ZM3ea-43' type='subscribed'></presence>

And the message has been sent with the request to receive receipts.

<message to='97.steve@xmpp1.call-genie.com' id='ZM3ea-44' type='chat'><body>hello</body><thread>a5d9542b-a3f9-45e2-ad46-b8d2371192af</thread><request xmlns='urn:xmpp:receipts'/><request xmlns='urn:xmpp:receipts'/></message>

However, I am still not seeing the onReceiptReceived being handled.

Many thanks for any additional information.

Not sure what you mean
The XMPP presence concept is based on subscriptions. The idea is to give users the control who can see their presence. See also RFC 6121 § 3.

DeliveryReceiptManager, per default, will only handle receipt requests from users which have a valid presence subscription to avoid presence leaks. See also DeliveryReceiptManager.setDefaultAutoReceiptMode().