When opening a pre-existing muc conference room, ejabberd server always relay last few messages from the previous muc session. OmemoRatcher throws the following exception on every relayed message received from server.
===== On every delayed omemo message received during setup =======
01-31 10:49:51.598 D/SMACK: RECV (0): <message xml:lang='en' to='swordfish@atalk.org/atalk' from='chatroom-ajwr@conference.atalk.org/leopard' type='groupchat' id='YQSGh-299'><archived by='chatroom-ajwr@conference.atalk.org' id='1517224235527360' xmlns='urn:xmpp:mam:tmp'/><stanza-id by='chatroom-ajwr@conference.atalk.org' id='1517224235527360' xmlns='urn:xmpp:sid:0'/><encrypted xmlns='eu.siacs.conversations.axolotl'><header sid='531601090'><key rid='1796289951'>MwohBemwEJsPC9wL9+BN2fN3lJ3sCzn76dZoJcLwsjFgK91PEAMYACIwC2dzs55GF+M+eYG4+sI0vXshxDcOR04L59A3qDa6mQH4Ru5oReDU197Z/1Q9WJPB3SMlH9OsIjc=</key><key rid='1584245149'>MwohBdZpO2Sa6S46PN4d+mggXRAZFjlXtqdDFkh6vZI/0FlWEAEYACIwLxm0aOer/9y7TOBODtKk9agJMA6+PZQFvFBxqGaaadxT3jkvxoNbo7Xa1vzYizzgUd/0WDGRgo0=</key><key rid='1155293484'>MwohBTRlt20TyDHWrbqfy3fjy/oWdm6bsn7l97afbjhlClMjEAAYASIw1RMzHTq3qt+KtFFdh9lU4kqz5xw2Yno7OX1iDcoXZFjVRg2DJTeh6bSsD1LLr0kK7rPTpSktFKY=</key><iv>NZTwIA5JmzxTQYs4OzpwFA==</iv></header><payload>0Aww</payload></encrypted><store xmlns='urn:xmpp:hints'/><encryption xmlns='urn:xmpp:eme:0' namespace='eu.siacs.conversations.axolotl' name='OMEMO'/><addresses xmlns='http://jabber.org/protocol/address'><address jid='leopard@atalk.org/atalk' type='ofrom'/></addresses><delay from='chatroom-ajwr@conference.atalk.org' stamp='2018-01-29T11:10:35.601438Z' xmlns='urn:xmpp:delay'/><body>I sent you an OMEMO encrypted message but your client doesn't seem to support that. Find more information on https://conversations.im/omemo</body></message>
01-31 10:49:51.599 D/SMACK: RECV (0): <message to='swordfish@atalk.org/atalk' from='chatroom-ajwr@conference.atalk.org' type='groupchat'><subject/></message>
01-31 10:49:51.605 E/aTalk: [27886] util.UtilActivator.uncaughtException().95 An uncaught exception occurred in thread=Thread[Thread-34,5,main] and message was: Attempt to invoke virtual method 'org.jxmpp.jid.Jid org.jivesoftware.smackx.muc.Occupant.getJid()' on a null object reference
java.lang.NullPointerException: Attempt to invoke virtual method 'org.jxmpp.jid.Jid org.jivesoftware.smackx.muc.Occupant.getJid()' on a null object reference
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1177)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:985)
at java.lang.Thread.run(Thread.java:762)
01-31 10:49:51.605 W/aTalk: [27888] org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived() Could not decrypt incoming message:
org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException: Transported key could not be decrypted, since no suitable message key was provided. Provides keys: [1796289951, 531601090]
at org.jivesoftware.smackx.omemo.OmemoRatchet.retrieveMessageKeyAndAuthTag(OmemoRatchet.java:123)
at org.jivesoftware.smackx.omemo.OmemoService.decryptMessage(OmemoService.java:447)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1188)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:985)
at java.lang.Thread.run(Thread.java:762)
During muc chat session, ejabber server will again relay every sent message to all the participants including the sender. OmemoRatchet on sender device will always throws CryptoFailedException since the sender rid key is absent in the relayed omemo sent message.
===== When sending each omemo message in chat room =======
01-31 11:04:25.595 D/SMACK: RECV (0): <message xml:lang='en' to='swordfish@atalk.org/atalk' from='chatroom-ajwr@conference.atalk.org/swordfish' type='groupchat' id='1xbGq-182'><archived by='chatroom-ajwr@conference.atalk.org' id='1517367866020091' xmlns='urn:xmpp:mam:tmp'/><stanza-id by='chatroom-ajwr@conference.atalk.org' id='1517367866020091' xmlns='urn:xmpp:sid:0'/><encrypted xmlns='eu.siacs.conversations.axolotl'><header sid='1155293484'><key rid='1796289951'>MwohBZIz9GxIwW/2442OFJmhRJiwElKC7WXP8PCjGNLmuWFsEAUYACIwu7dPY3xy5AlVhULYl/o8Sl9kJ3C3sNclHOYpMQE0RH7KzLUpH9Q0kQC8HdKNeua9XruIYf+UB5Y=</key><key rid='531601090'>MwohBfvdYByG70cXqvQLuZpc/J+CmF1/jUXv1CfGC+uXpvMaEAAYASIwZRq1R7TXR4k/vnkf5Ll99Zxxf1IoeQNIspvP6HjiNfjpKEDFgx9pIc9jpRUG1UNd0qNo6uO3zYo=</key><iv>CGKuKqfRIotlHbS3TN6QrQ==</iv></header><payload>gjnG</payload></encrypted><store xmlns='urn:xmpp:hints'/><encryption xmlns='urn:xmpp:eme:0' namespace='eu.siacs.conversations.axolotl' name='OMEMO'/><body>I sent you an OMEMO encrypted message but your client doesn't seem to support that. Find more information on https://conversations.im/omemo</body></message>
01-31 11:04:25.605 W/aTalk: [27975] org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived() Could not decrypt incoming message:
org.jivesoftware.smackx.omemo.exceptions.CryptoFailedException: Transported key could not be decrypted, since no suitable message key was provided. Provides keys: [1796289951, 531601090]
at org.jivesoftware.smackx.omemo.OmemoRatchet.retrieveMessageKeyAndAuthTag(OmemoRatchet.java:123)
at org.jivesoftware.smackx.omemo.OmemoService.decryptMessage(OmemoService.java:447)
at org.jivesoftware.smackx.omemo.OmemoService.onOmemoMessageStanzaReceived(OmemoService.java:1188)
at org.jivesoftware.smackx.omemo.OmemoManager$3$1.run(OmemoManager.java:985)
at java.lang.Thread.run(Thread.java:762)