1

Topic: ActiveSync causing Nginx errors 499 (undefined) and 502 Bad Gateway

==== Required information ====
- iRedMail version (check /etc/iredmail-release): 0.9.7 MARIADB edition.
- Linux/BSD distribution name and version: Debian 9 Stretch
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? Not yet
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====

Hi ZhangHuangbin  smile

I've recently started using iRedMail on a test site, and I'm seeing lots of 499 and 502 errors from Nginx:

--------------------- httpd Begin ------------------------


Connection attempts using mod_proxy:
    51.15.146.5 -> www.msftncsi.com:443: 3 Time(s)

Requests with error response codes
    400 Bad Request
       www.msftncsi.com:443: 3 Time(s)
    499 (undefined)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGSMG389F: 621 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGSMG390Y: 310 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG389F: 300 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... iceType=Android: 194 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGGTS7710: 147 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG390Y: 131 Time(s)
       /Microsoft-Server-ActiveSync?User=xyz@ ... iPhone&Cmd=Ping: 102 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGSMG389F: 100 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGSMG388F: 51 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGSMG390Y: 45 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =samsungSMG900I: 37 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGGTS7710: 29 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGSMG388F: 29 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... iceType=Android: 24 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG388F: 8 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=OPTIONS&U ... =SAMSUNGGTS7710: 1 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Search&Us ... iceType=Android: 1 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... iceType=Android: 1 Time(s)
       /Microsoft-Server-ActiveSync?User=xyz@ ... iPhone&Cmd=Sync: 1 Time(s)
    502 Bad Gateway
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGSMG389F: 158 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG389F: 84 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGGTS7710: 78 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGSMG390Y: 70 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... iceType=Android: 38 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG390Y: 30 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGSMG389F: 25 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =samsungSMG900I: 21 Time(s)
       /Microsoft-Server-ActiveSync?User=xyz@ ... iPhone&Cmd=Ping: 18 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGSMG388F: 12 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGSMG390Y: 10 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Sync&User ... =SAMSUNGSMG388F: 8 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG388F: 7 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... =SAMSUNGGTS7710: 4 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=FolderSyn ... iceType=Android: 3 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Search&Us ... iceType=Android: 1 Time(s)
    504 Gateway Timeout
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG389F: 1 Time(s)
       /Microsoft-Server-ActiveSync?Cmd=Ping&User ... =SAMSUNGSMG390Y: 1 Time(s)

---------------------- httpd End -------------------------

There is only one error-type in the Nginx logging, though - all the same as this:

2017/11/19 18:54:12 [error] 521#521: *101616 recv() failed (104: Connection reset by peer) while reading response header from upstream, client: {ip-addr}, server: _, request: "POST /Microsoft-Server-ActiveSync?Cmd=Sync&User={email-addr}&DeviceId={stripped}&DeviceType=SAMSUNGSMG390Y HTTP/1.1", upstream: "http://127.0.0.1:20000/SOGo/Microsoft-S … UNGSMG390Y", host: "{domain-name}"

I'm having trouble finding out how to reduce these errors.  Can you help?

Thanks!

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: ActiveSync causing Nginx errors 499 (undefined) and 502 Bad Gateway

How many ActiveSync clients (mostly mobile devices) do you have?

3

Re: ActiveSync causing Nginx errors 499 (undefined) and 502 Bad Gateway

ZhangHuangbin wrote:

How many ActiveSync clients (mostly mobile devices) do you have?

Somewhere between 20 and 40 I believe.  It roughly correlates to one error log line per mobile device.  Primarily Android.

4

Re: ActiveSync causing Nginx errors 499 (undefined) and 502 Bad Gateway

What's the prefork SOGo child processes set in /etc/default/sogo? It must be >= the activesync clients.

5

Re: ActiveSync causing Nginx errors 499 (undefined) and 502 Bad Gateway

Sorry for the delay!  I just checked... the PREFORK setting was 5.  I've put that up to 50 to see if it helps.

That said, I'm pretty sure we were seeing errors even with only one client?  But I'll watch and see.

If we still get errors, is there a better log file I should send you?

Thanks!

6

Re: ActiveSync causing Nginx errors 499 (undefined) and 502 Bad Gateway

Update - I only just discovered a bunch of "No child available" errors in /var/log/sogo/sogo.log.  They stopped immediately after I raised the PREFORK setting, so I think you fixed it!

Thanks ZhangHuangbin!