@Vivi I’m sorry, I have overlooked that there’s indeed an error:
2016-03-29 13:32:53 1 [syncadapter.SyncManager] Listing remote entries
2016-03-29 13:32:53 1 [HttpClient$1] --> REPORT https://myserver.org:444/owncloud/remote.php/caldav/calendars/MyAccount/perso/ http/1.1
2016-03-29 13:32:53 1 [HttpClient$1] Content-Type: application/xml; charset=utf-8
2016-03-29 13:32:53 1 [HttpClient$1] Content-Length: 269
2016-03-29 13:32:53 1 [HttpClient$1] Depth: 1
2016-03-29 13:32:53 1 [HttpClient$1]
2016-03-29 13:32:53 1 [HttpClient$1] <?xml version='1.0' encoding='UTF-8' ?><CAL:calendar-query xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav"><prop><getetag /></prop><CAL:filter><CAL:comp-filter name="VCALENDAR"><CAL:comp-filter name="VEVENT" /></CAL:comp-filter></CAL:filter></CAL:calendar-query>
2016-03-29 13:32:53 1 [HttpClient$1] --> END REPORT (269-byte body)
2016-03-29 13:32:53 1 [HttpClient$PreemptiveAuthenticationInterceptor] Adding basic authorization header for user MyAccount
2016-03-29 13:33:53 1 [HttpClient$1] <-- 504 Gateway Time-out https://myserver.org:444/owncloud/remote.php/caldav/calendars/MyAccount/perso/ (60618ms)
2016-03-29 13:33:54 1 [HttpClient$1] Server: nginx
2016-03-29 13:33:54 1 [HttpClient$1] Date: Tue, 29 Mar 2016 11:33:52 GMT
2016-03-29 13:33:54 1 [HttpClient$1] Content-Type: text/html
2016-03-29 13:33:54 1 [HttpClient$1] Content-Length: 176
2016-03-29 13:33:54 1 [HttpClient$1] Connection: keep-alive
2016-03-29 13:33:54 1 [HttpClient$1] Keep-Alive: timeout=20
2016-03-29 13:33:54 1 [HttpClient$1] OkHttp-Sent-Millis: 1459251173388
2016-03-29 13:33:54 1 [HttpClient$1] OkHttp-Received-Millis: 1459251233992
2016-03-29 13:33:54 1 [HttpClient$1]
2016-03-29 13:33:54 1 [HttpClient$1] <html>
<head><title>504 Gateway Time-out</title></head>
<body bgcolor="white">
<center><h1>504 Gateway Time-out</h1></center>
<hr><center>nginx</center>
</body>
</html>
2016-03-29 13:33:54 1 [HttpClient$1] <-- END HTTP (176-byte body)
2016-03-29 13:33:54 1 [syncadapter.SyncManager] HTTP/DAV Exception during sync
EXCEPTION at.bitfire.dav4android.exception.HttpException: 504 Gateway Time-out
at at.bitfire.dav4android.DavResource.checkStatus(DavResource.java:317)
at at.bitfire.dav4android.DavResource.checkStatus(DavResource.java:290)
at at.bitfire.dav4android.DavCalendar.calendarQuery(DavCalendar.java:88)
at at.bitfire.davdroid.syncadapter.CalendarSyncManager.listRemote(CalendarSyncManager.java:115)
at at.bitfire.davdroid.syncadapter.SyncManager.performSync(SyncManager.java:161)
at at.bitfire.davdroid.syncadapter.CalendarsSyncAdapterService$SyncAdapter.onPerformSync(CalendarsSyncAdapterService.java:64)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)
So, OwnCloud takes too long to scan through the calendar, which causes your Webserver, which apparently has a 60-second timeout for gateways (like FastCGI), to abort the request and send an error message.
With other sync clients, it may work because they use PROPFIND
instead of REPORT
, which may be faster (but less suitable, because it doesn’t return only events, but all entries, including tasks, which would cause unnecessary sync overhead).
Please note that this timeout is not imposed by DAVdroid (which uses a 120 second read timeout).
I guess your nginx FastCGI timeout is set to 60 seconds, which is the default value. It means that if PHP (running as FastCGI) doesn’t send an answer within 60 seconds, nginx will abort and send a Gateway timeout.
Try setting fastcgi_read_timeout
accordingly (for instance, 120 seconds). However, more than 60 seconds to enumerate 4000 entries is quite long (really, it shouldn’t take more than a few seconds when the database is used correctly), so I suggest improving OwnCloud performance, too. See also the OwnCloud timeout thread. Of course, not having calendars with that many entries is also a workaround.