fmbiete / Z-Push-contrib

Z-Push fork with changes that I will try to contrib
GNU Affero General Public License v3.0
134 stars 62 forks source link

Very large email in sync'd IMAP folder blows up Z-Push #183

Open ghost opened 9 years ago

ghost commented 9 years ago

Ran into this today..... I sent a very large logfile via email to a client; ~5MB or so of data, from my desktop. No problem, right?

Well, not on the desktop. But on my mobile Z-Push kept trying to sync that since it was in the "Sent" folder and continually failed. It never marked the item "unsyncable" but DID keep forcing resyncs which did some really ugly things to my phone's performance and battery life.

Ideas (I segregated the SENT folder for the phone for now in the IMAP backend to prevent it from happening right away, but this looks like a problem since the message itself was certainly valid.)

fmbiete commented 9 years ago

You should look for error in your logs. I have received without problems messages bigger. Also look at this php.ini param, maybe you should raise it:

memory_limit = 128M
ghost commented 9 years ago

I don't think that's what's going on -- it appears to be a time-related thing in that the time required to sync that specific message is long enough that it times out and thus never completes.

fmbiete commented 9 years ago

Look then to this parameters:

post_max_size = max size for your messages
max_execution_time = 900
max_input_time = 300

That 300 should be big enough, so the mobile can complete the post.

ghost commented 9 years ago

I'll play with this over the next few days; two of those three parameters are not in the config files anywhere and the last one has an attempt to set it to zero (unlimited) -- but, I believe that may be onto something as the Apache web server that's in front of all this does not permit unlimited cgi time limits and will abort connections that run for too long.

fmbiete commented 9 years ago

No, those parameters are in the php.ini file of your server.

I don't use apache, but in your case something like this could work in a .htaccess or in your virtualhost/directory conf:

php_value memory_limit 128M
php_value post_max_size 30M
php_value max_execution_time 900
php_value max_input_time 300

Maybe you will need to change something else in apache, so if someone out there knows a sane configuration, please share it and I will paste it in the INSTALL file for future reference :grin:

ghost commented 9 years ago

Is it expected behavior that if your mobile is out of contact for a while (e.g. out of range of a cell signal) that emails that come in may NEVER sync to the mobile? I was out of range intermittently for a few hours today and found two messages, new on the server, that were never sent over to the mobile.

fmbiete commented 9 years ago

No, it's not expected. If the mobile is out of sync it should resync. BUT, in my experience; some devices will take a lot of time to do it and others will need to reboot. It seems that the ActiveSync process will hang in the client side and will not contact again with the server (or will take a lot of time to do it). Enabling the access log in your nginx/apache will help you with that.

ghost commented 9 years ago

The missing emails were in the middle; ones that came in during the time the mobile was out of range. I continued to receive immediate updates on later messages (when I was back in range.) I didn't know there were missing messages until I signed into my laptop later on which syncs over IMAP directly, and found three unread and new emails that were not on the mobile.

It looks like (without detail logs, however, I can't be sure) the host lost contact and after some period of being unable to sync a particular message it gave up and never tried again; other, later messages went through without incident.

I will continue to try to run this down.

ghost commented 9 years ago

I have not been able to reproduce the missing emails despite a couple of attempts..... looks like some sort of glitch, but I'm not sure what caused it.

However, what I have been able to reproduce is that if I write something and it gets saved to "Drafts" on the desktop, and syncs to the mobile, when the desktop removes it (after it sends the email) it remains on the mobile and does NOT delete itself despite being gone (confirmed) on the server.

This is reliably repeatable.

fmbiete commented 9 years ago

@tickerguy search into your logs for Sync operations against the Drafts folder (in WBXML you can identify the folder asked for). In my phone only Sent and Inbox are automatically synced, everything else is synced only when opened in the client.

ghost commented 9 years ago

Oh it's being sync'd, and I can't shut it off in my phone either; it's a "no choice" checkbox on BlackBerry 10 (Drafts, Sent and Inbox are checked and cannot be unchecked.) What surprises me is that the items that make it into Drafts on the desktop sync to the handset (ok in the rare event I have to abandon a message before sending it and then can pick it up on the handset) but what's odd is that when sent they should disappear because they're deleted on the PC -- and yet they don't go away on the handheld. Messages I archive or delete in the INBOX, on the other hand, DO go away on the handheld (as expected.)

fmbiete commented 9 years ago

Is your desktop client Outlook?? That client doesn't fully synchronize the special folders as Draft. If possible test with thunderbird or some webmail client.

ghost commented 9 years ago

No, it's Thunderbird....