Type: Bug
Summary: No message (text/emoji, /request, /location, /send) received by the contact in 1-1, group chat when a message is sent to the contact which appears online after been ~10 minutes offline, until the contact re-log in into account.
Please note, messages have been sent to user when he is online.
The key of this case is: to go offline for 10 minutes and get back online without restarting the app.
When I send a message to contact which is online now (but it was offline for 10 minutes or more before), - this contact receives message fine.
When I send a message to contact which is online now (but it was offline for 10 minutes or more before), - this contact won't receive this message (until he re-login into account).
1) Open Status on Device1 and create account
2) Open Status on Device2 and create account
3) Device1 adds Device2 in contacts
4) Device1 sends message to Device2 and vice versa. Confirm both messages appears on both devices, with 'Delivered' statuses.
5) Turn Airplane mode ON on Device1
6) Wait >= 10 minutes
7) Turn Airplane mode OFF on Device1. Navigate to 1-1 chat you had before with Device2.
8) Device2 sends text message to Device1.
Actual result: No message received on Device1 side.
It was noticed that if to proceed above scenario with one more step:
9) Device1 sends text message to Device2.
Actual result: Message appeared on Device2 side, however, there is no 'Delivered' status on Device1 side for this message.
If in the 6th step above to stay in Offline mode for 2-3 minutes - everything will be fine with further messaging between both contacts.
Transactions are sent and received fine in that case.
TF session representing device1 (after 10 minutes it was in offline - so from 7th step in reproduction steps above): https://app.testfairy.com/projects/4803590-status/builds/7549901/sessions/28/?accessToken=JG8aPNFDnrenko-rzf-QvsgFnX8
TF session representing device2 (after 10 minutes Device2 was in offline) - from 09:48: https://app.testfairy.com/projects/4803622-status/builds/7534654/sessions/60/?accessToken=tMUthBlmxQzJfiVOdk4YjhfRA9M
I wonder if this is related to the log entries we're seeing in https://github.com/status-im/status-react/issues/3096, which also happens after similar conditions are met.
Current balance: 0.000000 ETH
Contract address: 0x95f27acdaf1a6d730f8e2c4f6b8c284f0afc8d3e

Network: Mainnet
To claim this bounty sign up at https://openbounty.status.im and make sure to update your Ethereum address in My Payment Details so that the bounty is correctly allocated.
To fund it, send ETH or ERC20/ERC223 tokens to the contract address.
I wonder if this is related to the log entries we're seeing in #3096, which also happens after similar conditions are met.
@PombeirP yes, you can find same log errors in TF session for device1.
OK, just so we remember to close that one once this is fixed. Oh, it's been done already, good!
Just found this issue linked to another one that I was investigating. Application needs to re-create a filter if it wasn't used for longer than 300s. Please see https://github.com/ethereum/go-ethereum/blob/master/whisper/whisperv5/api.go#L76-L82 . That is by whisper design, used to prevent leaks of not used filters. The only thing we can do is to increase this "idle" timeout, but I doubt that it will make any meaningful change.
GitHub
go-ethereum - Official Go implementation of the Ethereum protocol
Also, it probably means that if app goes to sleep then all messages received by the geth node during that time won't be received by the app itself (because a filter is removed after 300s). Seems like a big issue to me).
We can disable that "cleaner", because we have only one filters consumer, and rely on status-react to always remove not used filters.
@dshulyak great find! I can confirm that it makes a difference, having created an Android build with the run() method commented out, I can keep on receiving new messages even after having left my phone alone for more than 10 minutes!
One important thing I want to point out, that status-go actually returned this error (filter not found).
I think we need to at least show some message if any of the web3 APIs returns an error. That would greatly simplify any debugging.
@dshulyak @PombeirP great! we can quickfix it with a patch. After that, it would be nice to upstream something that optionally disables this "garbage collection" because it isn't really compatible with any mobile use-case.
Btw, Whisper V6, does it also have this behaviour?
@mandrigin yeah, that was also my hope, but unfortunately the code stayed the same there.
Actually, there is an even better way to handle this without disabling a "cleaner". Whisper API provides subscription available on shh_messages, this subscription will create and poll filter internally every 250 ms. This way status-react doesn't have to poll shh_getFilterMessages in the foreground, and filter will be always open until the subscription will be explicitly closed.
Is there any reason why shh_messages cannot be used? https://web3js.readthedocs.io/en/1.0/web3-shh.html#subscribe
If we update status-go to the latest develop, it should be fixed.
→ https://github.com/status-im/status-react/pull/3236 is the current update PR
It would be great to have some insight from the status-react side because something is off. I believe it works this way:
It does resume and prints messages in the logs, but it seems like the log level is off. And the polling continues.
But how can it continue if the filter is gone? Unless this code is executed: https://github.com/ethereum/web3.js/blob/62dd77c7f43522eb568a001cf4c4df726f8efa69/lib/web3/requestmanager.js#L234-L236 which simply ignores any error...
GitHub
web3.js - Ethereum JavaScript API
My debugger in Xcode tells me that the web3 methods are still being called. I didn't dive deep into the client-side code to figure out why.
I 100% agree with you that we need to investigate. Otherwise, it would be very hard to debug similar issues.
Most helpful comment
Just found this issue linked to another one that I was investigating. Application needs to re-create a filter if it wasn't used for longer than 300s. Please see https://github.com/ethereum/go-ethereum/blob/master/whisper/whisperv5/api.go#L76-L82 . That is by whisper design, used to prevent leaks of not used filters. The only thing we can do is to increase this "idle" timeout, but I doubt that it will make any meaningful change.