Message never download
Checklist
- [X] I have used the search function to see if someone else has already submitted the same bug report.
- [X] I will describe the problem with as much detail as possible.
App version
6.201
Where did you get the app from?
Google Play
Android version
12
Device model
Samsung A53
Steps to reproduce
I have my own imap server running on gofer.mess.org. This works fine with other email clients like evolution. However, k9 fails to download messages.
The dovecot server encounters an error in its cache.
Aug 01 15:39:20 gofer.mess.org dovecot[1315]: imap-login: Login: user=<sean>, method=PLAIN, rip=2a02:8011:d000:212:f343:4db1:ea4:ab3, lip=2a02:8011:d000:212::1, mpid=754957, TLS, session=<5fUV9y7lhOkqAoAR0AACEvNDTbEOpAqz>
Aug 01 15:39:21 gofer.mess.org dovecot[1315]: imap(sean)<754957><5fUV9y7lhOkqAoAR0AACEvNDTbEOpAqz>: Error: Mailbox mess: Deleting corrupted cache record uid=83109: UID 83109: Broken physical size in mailbox mess: read(/home/sean/Mail/mess) failed: Cached message size smaller than expected (4742 < 4752, box=mess, UID>
Aug 01 15:39:21 gofer.mess.org dovecot[1315]: imap(sean)<754957><5fUV9y7lhOkqAoAR0AACEvNDTbEOpAqz>: Error: Mailbox mess: UID=83109: read(/home/sean/Mail/mess) failed: Cached message size smaller than expected (4742 < 4752, box=mess, UID=83109) (FETCH BODY[])
Aug 01 15:39:21 gofer.mess.org dovecot[1315]: imap(sean)<754957><5fUV9y7lhOkqAoAR0AACEvNDTbEOpAqz>: FETCH read() failed in=860 out=67650 deleted=0 expunged=0 trashed=0 hdr_count=59 hdr_bytes=35807 body_count=2 body_bytes=10844
This causes k9 to just hang and sit forever fetching mail. The progress bar does not advance.
To recover from this, I need to do the following steps:
- kill k9 (it is just stuck forever)
-
rm -rfthe dovecot cache files - restart k9
Note that evolution and other imap clients have I tried do not have this issue.
Please note I have been donating to k9 mail via Liberapay for some time now.
Expected behavior
When the imap server does not behave, try again. Other mail clients manage to do this.
Actual behavior
k9 just sits idle forever and eats battery
Logs
From the log it looks like the connection never times out.
That could mean the server is (constantly) sending data so the read timeout (60 seconds) doesn't trigger. If that's the case, it is data that the response parser treats as one long response, because after successfully parsing a response line, a message will be written to the log (and there is none). Another possibility is that there's a bug in the Android version on your device and the read timeout is ignored.
To find out what exactly is going on you'd need to record the network traffic between your Android device and your server, e.g. via a tool like Wireshark.
I've done a tcp dump of a typical connection where k9 mail stops responding. Actually I can't see why the communication just stops. There is no activity on the tcp port after this, from either side.
@cketti ?
Everything looks fine to me up until the end. It does look like the end of the log is missing. There's no reason for the server to just stop transmitting data where the log ends. If it did, K-9 Mail should still run into a read timeout.
I've just tried it again and the same result:
- The dovecot server log contains an error saying its cache file is corrupted, and stop sending
- k9mail never goes into a read timeout and just "hangs" until I kill it
Can I help to debug this problem?
Not running into a read timeout could be a bug in the Android version on your device. Can you test this using another Android device?
You should also report a bug to dovecot. If the server runs into such an error, it should at least close the connection.
I've lived with this bug for some time, and I've had different android phones and versions of k9 mail.
So how do we debug this problem?
k9 is the only imap client that cannot deal with the misbehaving dovecot server.
Sorry, it doesn't feel like trying to debug this issue remotely is a good use of my time. The amount of users being affected by this bug is likely very small. It seems like you could work around this by simply fixing the broken Dovecot cache.
As for debugging, you could try building a debug version of K-9 Mail and then attaching a debugger to see where the app is hanging exactly. Then come up with a test to reproduce the exact circumstances leading to the app hanging.
Thanks for the help @cketti
I've stopped my librapay donations