Davdroid no longer works with NC

I just migrated from Owncloud to Nextcloud today. I did so by installing Nextcloud and then importing my Database into Nextcloud. So far, Nextcloud works wonderfully but the only thing that doesn’t work is Davdroid, which is an app on Android I use to sync my calendar and contacts with my phone. Authentication passes in Davdroid, it’s even able to see which calendars I have. When it goes to fetch data from my contacts, it all falls apart.

Error output is below. Note I changed “https” to “httpx” to get around the “two link” limitation this output trips. I also masked my nextcloud URL.

Account name: jay@mydomain.com

PROPFIND /remote.php/dav/principals/users/jay/
Content-Length: 360
Content-Type: application/xml; charset=utf-8
Depth: 0

<?xml version='1.0' encoding='UTF-8' ?><propfind xmlns="DAV:" xmlns:CAL="urn:ietf:params:xml:ns:caldav" xmlns:CARD="urn:ietf:params:xml:ns:carddav"><prop><CAL:calendar-home-set /><n0:calendar-proxy-read-for xmlns:n0="http://calendarserver.org/ns/" /><n1:calendar-proxy-write-for xmlns:n1="http://calendarserver.org/ns/" /><group-membership /></prop></propfind>jaylacroix

http/1.1 503 Service Unavailable
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection: close
Content-Length: 0
Content-Security-Policy: default-src 'self'; script-src 'self' 'unsafe-eval'; style-src 'self' 'unsafe-inline'; frame-src *; img-src * data: blob:; font-src 'self' data:; media-src *; connect-src *
Content-Type: text/html; charset=UTF-8
Date: Tue, 14 Jun 2016 17:56:47 GMT
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Pragma: no-cache
Server: Apache/2.4.10 (Debian)
Set-Cookie: oc_sessionPassphrase=nqM1pEV2AflADSY52VAIt2sooennO9A0RRAE8CVFBLQaZMPSDhNGkxBHGsI%2F1nh93gwwk5o5tBJtRst0%2BcfNdJsb6lY7wVy3%2FEiUES320h2D6bu7uAMv8OQgb3lqWCiU; path=/; secure; httponly
Set-Cookie: nc_sameSiteCookielax=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax
Set-Cookie: nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict
Strict-Transport-Security: max-age=15768000; includeSubDomains; preload
X-Content-Type-Options: nosniff
X-Download-Options: noopen
X-Frame-Options: SAMEORIGIN
X-Permitted-Cross-Domain-Policies: none
X-Robots-Tag: none
X-XSS-Protection: 1; mode=block

at.bitfire.dav4android.exception.ServiceUnavailableException: 503 Service Unavailable
	at at.bitfire.dav4android.DavResource.checkStatus(DavResource.java:315)
	at at.bitfire.dav4android.DavResource.checkStatus(DavResource.java:290)
	at at.bitfire.dav4android.DavResource.propfind(DavResource.java:275)
	at at.bitfire.davdroid.DavService$RefreshCollections.queryHomeSets(DavService.java:347)
	at at.bitfire.davdroid.DavService$RefreshCollections.run(DavService.java:196)
	at java.lang.Thread.run(Thread.java:818)

DAVdroid version: (102) Sat Jun 11 03:12:40 EDT 2016
Installed from: com.android.vending
JB Workaround installed: no

System-wide synchronization: automatically
Account: jay@mydomain.com
  Address book sync. interval: 240 min
  Calendar     sync. interval: 240 min
  OpenTasks    sync. interval: 240 min

	|  locale |
	|  en_US |
	|  setting | value |
	|  _id | accountName | service | principal |
	|  8 | jay@mydomain.com | carddav | httpx://nextcloud.mydomain.com/remote.php/dav/principals/users/jay/ |
	|  9 | jay@mydomain.com | caldav | httpx://nextcloud.mydomain.com/remote.php/dav/principals/users/jay/ |
	|  name | seq |
	|  services | 9 |
	|  collections | 21 |
	|  homesets | 16 |
	|  _id | serviceID | url |
	|  15 | 8 | httpx://nextcloud.mydomain.com/remote.php/dav/addressbooks/users/jay/ |
	|  16 | 9 | httpx://nextcloud.mydomain.com/remote.php/dav/calendars/jay/ |
	|  _id | serviceID | url | readOnly | displayName | description | color | timezone | supportsVEVENT | supportsVTODO | sync |
	|  19 | 8 | httpx://nextcloud.mydomain.com/remote.php/dav/addressbooks/users/jay/default/ | 0 | default | <null> | <null> | <null> | <null> | <null> | 1 |
	|  20 | 9 | httpx://nextcloud.mydomain.com/remote.php/dav/calendars/jay/default/ | 0 | Main | <null> | <null> | <null> | 1 | 1 | 0 |
	|  21 | 9 | httpx://nextcloud.mydomain.com/remote.php/dav/calendars/jay/contact_birthdays/ | 1 | contact_birthdays | <null> | <null> | <null> | 1 | 1 | 0 |

Android version: 6.0.1 (MOB30M)
Device: LGE Nexus 5 (hammerhead)

The request seems to miss some information, I don’t happen to have an Android device at hand so is there any chance you can intercept the whole request?

I’m especially wondering what kind of cookies are sent with it. Also is anything in the server logs?

I just asked a friend of mine who is using Nextcloud 9 as well with DAVDroid and all works for him. So a traffic capture would really be helpful :slight_smile:

Hi, I have no problems here with Nextcloud 9.0.50 and Davdroid (Contacts & calendar)
Everything sync well.

Shouldn’t it say remote.php/CALdav/ instead of /dav/?

Just wondering…

Hi, Long time OwnCloud user here - have just migrated to NextCloud all went relatively smoothly; so well done guys!

Just to chime in here, I noticed that the request above states that you are receiving back an http response of 503. I also upon upgrading got that response after logging into the web interface. Looking at the server log it was writing back:

[Tue Jun 14 17:18:51.690844 2016] [autoindex:error] [pid 23283] [client] AH01276: Cannot serve directory /storage/WWW/cloud.domain.com/public_html/apps/files/: No matching DirectoryIndex (index.php,index.html) found, and server-generated directory index forbidden by Options directive

Did some further digging and it appears to be an issue with the .htaccess that’s been packaged with Nextcloud, at least it is with the version of Apache I’m using (same as above except on Fedora) . I didn’t have time to do a diff with the Owncloud .htaccess file - but swapping them over did solve my issue entirely.

For what it’s worth:

Despite the contacts app giving https://server.to/path/remote.php/dav/addressbooks/user/addressbook-name as the Carddav-Link, this would not work for me.

https://server.to/path/remote.php/CARDdav/addressbooks/user/addressbook-name on the other hand works like charme.

This said: I’m using the carddav sync app not davdroid!

I tried downloading the .htaccess file from owncloud and dropping that in, but it did not solve the issue for me.

Unfortunately, I’m not sure how to capture the traffic.

I’m really not sure why this isn’t working. Nextcloud is supposed to be a drop-in replacement for Owncloud, correct? I have Davdroid configured the exact same way as I did when I was using Owncloud, and I configured Nextcloud the exact same way as I did with Owncloud. I’m using the same URL with Davdroid. What I find odd is that Davdroid is logging in successfully with Nextcloud, as it’s able to see my Calendar names and the fact that I have contacts, it just isn’t allowed to download anything.

I see the following information in my Apache logs:
[Tue Jun 14 14:29:28.055812 2016] [authz_core:error] [pid 4661] [client] AH01630: client denied by server configuration: /var/www/nextcloud.mydomain.com/data/htaccesstest.txt
[Tue Jun 14 14:30:43.503511 2016] [negotiation:error] [pid 11574] [client] AH00687: Negotiation: discovered file(s) matching request: /var/www/nextcloud.mydomain.com/settings/personal (None could be negotiated).

But what’s strange is that when I tail -f my Apache logs, I see no new entries, even when I repeatedly try to sync contacts, so I’m not really sure that’s totally related.

That’s strange - those entries look like they are disallowing direct access to data/ which is correct. I notice that you’re trying to access a file called htaccesstest.txt in the data directory - probably a stupid question, but the .htaccess file you took from owncloud did you put that in your nextcloud root or the data directory and did you definitely name it “.htaccess”.

Other than that if you are continually getting 503 responses from davdroid and you are not seeing any new apache log messages, what does your logging configuration look like?

The relevant line in the apache config is this:

ErrorLog ${APACHE_LOG_DIR}/nextcloud.mydomain.com_error.log

Could everybody that is affected by this issue test whether https://github.com/nextcloud/server/pull/110 resolves it? That would be helpful. Patching lib/private/appframework/http/request.php is sufficent.

I patched that file, and I’m still getting the same error. Disclaimer though, I am a newbie in regards to Github, so I manually copied and pasted your changes from the file on Github to the file on my server as best I could, but I’m fairly certain that I did it right.

So from what ownCloud version did you upgrade to Nextcloud, 9.0.x or 8.2.x?

I migrated from 9.0.x.

Quick update everyone. I reinstalled Owncloud in another directory on the same server, with a different URL and database. I set up DAVDroid with Owncloud, and it works perfectly with the same settings and I have no problems whatsoever.

So now I have both Nextcloud and Owncloud on the same server, so I can test Nextcloud to eventually migrate over to it. But unfortunately, until I can get contact syncing working on my phone, I guess I’ll have to stick with Owncloud for my productivity for now until the Nextcloud bugs get worked out.

But on the brightside, since I have both OC and NC installed side by side, it will help me test should be there be anything I can do to help you guys troubleshoot and fix this bug.

I upgraded from ownCloud 8.2 to Nextcloud 9, and I am having this problem with Davdroid. I will let you know if the patch above solves the problem once I’ve tried it.

It didn’t help for me.

I upgraded from ownCloud 9 and got the same problem. With Apache 2.4 and php7 on debian jessie. I applied the patch didn’t help.

Davdroid log is giving:

2016-06-19 10:24:31 15 [dav4android.DavResource] Received for https://mydomain.com/remote.php/dav/addressbooks/users/user/calendar/
PARAMETER #1 = [getctag(http://calendarserver.org/ns/): GetCTag(cTag=55), supported-address-data(urn:ietf:params:xml:ns:carddav): at.bitfire.dav4android.property.SupportedAddressData@10ca3539]
2016-06-19 10:24:31 15 [syncadapter.ContactsSyncManager] Server advertises VCard/4 support: true
2016-06-19 10:24:31 15 [syncadapter.SyncManager] Processing locally deleted entries
2016-06-19 10:24:31 15 [syncadapter.SyncManager] Locally preparing dirty entries
2016-06-19 10:24:31 15 [syncadapter.SyncManager] Uploading dirty entries
2016-06-19 10:24:31 15 [syncadapter.SyncManager] Checking sync state
2016-06-19 10:24:31 15 [syncadapter.SyncManager] Manual sync, ignoring CTag
2016-06-19 10:24:31 15 [syncadapter.SyncManager] Listing local entries
2016-06-19 10:24:31 15 [syncadapter.SyncManager] Listing remote entries
2016-06-19 10:24:31 15 [HttpClient$1] --> REPORT https://mydomain.com/remote.php/dav/addressbooks/users/user/calendar/ http/1.1
2016-06-19 10:24:31 15 [HttpClient$1] Content-Type: application/xml; charset=utf-8
2016-06-19 10:24:31 15 [HttpClient$1] Content-Length: 184
2016-06-19 10:24:31 15 [HttpClient$1] Depth: 1
2016-06-19 10:24:31 15 [HttpClient$1]
2016-06-19 10:24:31 15 [HttpClient$1] <?xml version='1.0' encoding='UTF-8' ?><CARD:addressbook-query xmlns=“DAV:” xmlns:CARD=“urn:ietf:params:xml:ns:carddav”><CARD:filter /></CARD:addressbook-query>
2016-06-19 10:24:31 15 [HttpClient$1] --> END REPORT (184-byte body)
2016-06-19 10:24:31 15 [HttpClient$PreemptiveAuthenticationInterceptor] Adding basic authorization header for user anni
2016-06-19 10:24:31 15 [HttpClient$1] <-- 503 Service Unavailablehttps://mydomain.com/remote.php/dav/addressbooks/users/user/calendar/ (94ms)
2016-06-19 10:24:31 15 [HttpClient$1] Date: Sun, 19 Jun 2016 08:24:33 GMT
2016-06-19 10:24:31 15 [HttpClient$1] Server: Apache/2.4.10 (Debian)
2016-06-19 10:24:31 15 [HttpClient$1] Strict-Transport-Security: max-age=15768000; includeSubDomains; preload
2016-06-19 10:24:31 15 [HttpClient$1] Expires: Thu, 19 Nov 1981 08:52:00 GMT
2016-06-19 10:24:31 15 [HttpClient$1] Cache-Control: no-store, no-cache, must-revalidate
2016-06-19 10:24:31 15 [HttpClient$1] Pragma: no-cache
2016-06-19 10:24:31 15 [HttpClient$1] Set-Cookie: oc_sessionPassphrase=#######; path=/; secure; HttpOnly
2016-06-19 10:24:31 15 [HttpClient$1] Content-Security-Policy: default-src ‘self’; script-src ‘self’ ‘unsafe-eval’; style-src ‘self’ ‘unsafe-inline’; frame-src *; img-src * data: blob:; font-src ‘self’ data:; media-src *; connect-src *
2016-06-19 10:24:31 15 [HttpClient$1] Set-Cookie: nc_sameSiteCookielax=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=lax
2016-06-19 10:24:31 15 [HttpClient$1] Set-Cookie: nc_sameSiteCookiestrict=true; path=/; httponly;secure; expires=Fri, 31-Dec-2100 23:59:59 GMT; SameSite=strict
2016-06-19 10:24:31 15 [HttpClient$1] X-Content-Type-Options: nosniff
2016-06-19 10:24:31 15 [HttpClient$1] X-XSS-Protection: 1; mode=block
2016-06-19 10:24:31 15 [HttpClient$1] X-Robots-Tag: none
2016-06-19 10:24:31 15 [HttpClient$1] X-Frame-Options: SAMEORIGIN
2016-06-19 10:24:31 15 [HttpClient$1] X-Download-Options: noopen
2016-06-19 10:24:31 15 [HttpClient$1] X-Permitted-Cross-Domain-Policies: none
2016-06-19 10:24:31 15 [HttpClient$1] Content-Length: 0
2016-06-19 10:24:31 15 [HttpClient$1] Connection: close
2016-06-19 10:24:31 15 [HttpClient$1] Content-Type: text/html; charset=UTF-8
2016-06-19 10:24:31 15 [HttpClient$1] <-- END HTTP (0-byte body)
2016-06-19 10:24:31 15 [syncadapter.SyncManager] I/O exception during sync, trying again later
EXCEPTION at.bitfire.dav4android.exception.ServiceUnavailableException: 503 Service Unavailable
at at.bitfire.dav4android.DavResource.checkStatus(DavResource.java:315)
at at.bitfire.dav4android.DavResource.checkStatus(DavResource.java:290)
at at.bitfire.dav4android.DavAddressBook.addressbookQuery(DavAddressBook.java:63)
at at.bitfire.davdroid.syncadapter.ContactsSyncManager.listRemote(ContactsSyncManager.java:153)
at at.bitfire.davdroid.syncadapter.SyncManager.performSync(SyncManager.java:160)
at at.bitfire.davdroid.syncadapter.ContactsSyncAdapterService$ContactsSyncAdapter.onPerformSync(ContactsSyncAdapterService.java:66)
at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:259)

2016-06-19 10:24:31 15 [syncadapter.ContactsSyncAdapterService$ContactsSyncAdapter] Address book sync complete

tail -f access.log gives: - arne [19/Jun/2016:10:53:05 +0200] “PROPFIND /remote.php/dav/addressbooks/users/arne/kontakte/ HTTP/1.1” 207 2140 “-” "DAVdroid/ (2016/06/12; dav4android; okhttp3) Android/5.1.1" - arne [19/Jun/2016:10:53:06 +0200] “REPORT /remote.php/dav/addressbooks/users/arne/kontakte/ HTTP/1.1” 503 1211 “-” “DAVdroid/ (2016/06/12; dav4android; okhttp3) Android/5.1.1”

error.log is unchanged.

Same problem here. I have a fresh NC Installation.
But Caldav android app works for me. So It look’s like a DavDroid Issue.

I’m running Nextcloud 9 and DavDroid and just double checked it. Seems to work for me. Although I have configured the account already before I switched to Nextcloud, maybe this makes a difference?