Smack 4.2.1-beta2-SNAPSHOT: No response received within reply timeout even when reply is received well within the specified PacketReplyTimeout

The reason for the exception is, that your SQLiteOmemoStore does throw an exception when trying to load a non-existent key. In case a key does not exist, smack-omemo expects the return value “null”. Your implementation throws an exception instead, which is bad. You should check, whether the database contains a serialized identityKey before trying to deserialize it.

Edit: I should definitely update the javadoc though to make it clear, that a null return value is expected in case there is no key.

Edit2: It is this line which causes the issue for you (given the source code on github is recent).

Sorry to incorrectly interpret the requirements. I suppose this also applied to the method loadOmemoIdentityKey(). After the correction, the omemoManager does proceed further to publish the generated prekeys.

Actually my old implementation was correct, but changed due to my incorrect interpretation.

In the case when the identityKeys is corrupted, what is your proposed action?
should I proceed to delete the corrupted identityKeys so the system can auto-recover on next launch. This was my previous implementation, but I commented out for new implementation, no sure if this is correct.

After the above fix, the following exception still exist for new account creation i.e.

  1. enableDisableCarbon reply timeout even reply is received within timeout period or stanza never get sent.
  2. pubsub.PubSubManager.tryToPublishAndPossibleAutoCreate always failed. No stanza being sent.

With #2 problem, I observe the following during testing:
3a. The problem device can still send omemo message, and display the sent text on the chat window. Everything seems normal.
3b. With the devicelist on the server, the recipient cannot fetch the key for message decryption, so it quietly discarded the received message.
Does the omemo protocol designed to behave this way?

Right now I only issue a toast message to user when corrupted identiyKeys happen, but did not block the sending of omemo message.

01-19 09:33:57.255 D/SMACK: SENT (0): <iq id='kmiCu-119' type='set'><enable xmlns='urn:xmpp:carbons:2'/></iq>
01-19 09:33:57.396 D/SMACK: RECV (0): <iq xml:lang='en' to='parrot@atalk.org/atalk' from='parrot@atalk.org' type='result' id='kmiCu-119'/>
01-19 09:34:07.264 E/aTalk: [12330] impl.protocol.jabber.OperationSetBasicInstantMessagingJabberImpl.enableDisableCarbon().748 Failed to set carbon state for: parrot@atalk.org/atalk to true
                            org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s). Waited for response using: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=kmiCu-119)), : fromFilter (OrFilter: (FromMatchesFilter (full): null, FromMatchesFilter (ignoreResourcepart): parrot@atalk.org, FromMatchesFilter (full): atalk.org)).
                                at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:253)
                                at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:208)
                                at org.jivesoftware.smackx.carbons.CarbonManager.setCarbonsEnabled(CarbonManager.java:311)
                                at net.java.sip.communicator.impl.protocol.jabber.OperationSetBasicInstantMessagingJabberImpl.enableDisableCarbon(OperationSetBasicInstantMessagingJabberImpl.java:739)
                                at net.java.sip.communicator.impl.protocol.jabber.OperationSetBasicInstantMessagingJabberImpl.initAdditionalServices(OperationSetBasicInstantMessagingJabberImpl.java:721)
                                at net.java.sip.communicator.impl.protocol.jabber.OperationSetBasicInstantMessagingJabberImpl.access$700(OperationSetBasicInstantMessagingJabberImpl.java:102)
                                at net.java.sip.communicator.impl.protocol.jabber.OperationSetBasicInstantMessagingJabberImpl$RegistrationStateListener$1.run(OperationSetBasicInstantMessagingJabberImpl.java:689)
                                at java.lang.Thread.run(Thread.java:762)
01-19 09:34:07.327 D/SMACK: XMPPConnection authenticated (XMPPTCPConnection[parrot@atalk.org/atalk] (0))
01-19 09:34:07.329 E/aTalk: [12329] org.atalk.crypto.omemo.AndroidOmemoService.initializationFailed().139 Initialize OmemoManager failed: 
                            org.jivesoftware.smack.SmackException$NoResponseException: No response received within reply timeout. Timeout was 10000ms (~10s). Waited for response using: IQReplyFilter: iqAndIdFilter (AndFilter: (OrFilter: (IQTypeFilter: type=error, IQTypeFilter: type=result), StanzaIdFilter: id=kmiCu-120)), : fromFilter (OrFilter: (FromMatchesFilter (full): parrot@atalk.org, FromMatchesFilter (full): null)).
                                at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:253)
                                at org.jivesoftware.smack.StanzaCollector.nextResultOrThrow(StanzaCollector.java:208)
                                at org.jivesoftware.smackx.pubsub.LeafNode.send(LeafNode.java:350)
                                at org.jivesoftware.smackx.pubsub.LeafNode.send(LeafNode.java:325)
                                at org.jivesoftware.smackx.pubsub.PubSubManager.tryToPublishAndPossibleAutoCreate(PubSubManager.java:403)
                                at org.jivesoftware.smackx.omemo.OmemoService.publishBundle(OmemoService.java:575)
                                at org.jivesoftware.smackx.omemo.OmemoService.init(OmemoService.java:259)
                                at org.jivesoftware.smackx.omemo.OmemoManager.initialize(OmemoManager.java:244)
                                at org.jivesoftware.smackx.omemo.OmemoManager$2.run(OmemoManager.java:260)
                                at java.lang.Thread.run(Thread.java:762)

There is no specification how to handle corrupted identityKeys, but I would definitely inform the user and ask what to do. If the user decides to generate new keys, you MUST also generate a new deviceId, otherwise it will look for contacts as if a “man in the middle attack” is happening.

Move to new topics:

Move to new topics: