gggard / AndroidCaldavSyncAdapater

Caldav synch adapter for Android
246 stars 88 forks source link

This used to work but now does not #229

Open alavarre opened 9 years ago

alavarre commented 9 years ago

I want to sync with the Nexus 4 Android. We had this working before, but things have changed. I now get

 Invalid server answer, check URL.

no matter what I've tried.

I am running OwnCloud 7.0.3 under an Apache2 server under Linux openSUSE 13.2. The 'droid is the Nexus 4. (and the Nexus 7). I have tried using the app from both Google PlayStore (v. 1.8.1) and F-droid (v 1.8.10)

OwnCloud works fine, no issues.

Evolution calendar syncs perfectly well with the DAV protocol dav:andy@http://192.168.5.2/owncloud/index.php/apps/calendar/remote.php/caldav/calendar

----------------------- Details ----------------------- 12/3/14

What worked before as a URL is http://192.168.5.2/owncloud/remote.php/caldav/

This now returns 
         Invalid server answer, check URL. 

In summary of the experimentation: we can find URLs that display the calendar folders and show the .ics file contents in a browser (from both the 'droid and the main machine) but for whatever reason the app fails to load them. We have tried both the version from f-droid and Google PlayStore.

Initially we had a warning that the configuration file did not have 192.168.5.2 as a trusted client, so we added that. We also added the 'droid address, (and restarted the server: service apache2 restart) but no joy.

So we must conclude that, since the URLs display correctly in the browsers, the application must be at fault.

This used to work:     http://192.168.5.2/owncloud/remote.php/caldav/ Loading this in a browser brings first a demand for username and password User:               andy Password:    OWNCLOUDbbs14@
Then shows two subdirectories: principals calendars both of which refuse to show their contents: <d:error xmlns:d="DAV:" xmlns:s="http://sabredav.org/ns"> Sabre\DAV\Exception\MethodNotAllowed /s:exception Listing members of this collection is disabled/s:message 1.8.10/s:sabredav-version /d:error

Putting any of the following in the Nexus app returns the standard complaint: (Invalid server answer, check URL):

    http://192.168.5.2/owncloud/remote.php/caldav/principals
    http://192.168.5.2/owncloud/remote.php/caldav/principals/Andy
    http://192.168.5.2/owncloud/remote.php/caldav/calendars/Andy/OwnCloud   
    http://192.168.5.2/owncloud/remote.php/caldav/calendars/Andy/
    http://192.168.5.2/owncloud/remote.php/caldav/calendars/Andy    
    http://192.168.5.2/owncloud/remote.php/caldav/calendars/    
    http://192.168.5.2/owncloud/remote.php/caldav/calendars
    http://192.168.5.2/owncloud/remote.php/caldav/
    http://192.168.5.2/owncloud/remote.php/caldav
    http://192.168.5.2/owncloud/remote.php/

In a browser
    http://192.168.5.2/owncloud/remote.php/caldav/principals/Andy
          shows two files
        calendar proxy-read
        calendar proxy-write

    http://192.168.5.2/owncloud/remote.php/caldav/calendars/Andy/
        shows all the calendars, and clicking on any of thems gives the list of .ics files.

But entering the entire URL (with or without the trailing /): 
        http://192.168.5.2/owncloud/remote.php/caldav/calendars/Andy/OwnCloud   
            returns a SaberDAV error:
                <d:error xmlns:d="DAV"
                    xlmns:s="http://sabredav.org/ns">
                    <s: exception:Sabre\DAV\Exception\NotFound</s:exception>
                    <s:message>Calendar with name 'OwnCloud'
                    could not be found</s:message>
                    <s:sabredav-version>1.8.10</s:sabredav-version>
                </d:error>

Evolution is syncing perfectly well but it has the URL
    dav:andy@http://192.168.5.2/owncloud/index.php/apps/calendar/remote.php/caldav/calendar
    Trying this returns The format of the URL is wrong
    and putting it in the 'droid browser fails, so it may not have the dav protocol

    So try
        http://192.168.5.2/owncloud/index.php/apps/calendar/remote.php/caldav/calendar
        which returns the standard error.
        But putting this in a browser gets us to the server, but doesn't sync to the local 'droid

Thanks in advance.

Cheers, Andy

ervee commented 9 years ago

I had a similar issue and had somethig to do with some clients (mosly on Android) are sending the server port number with their http request. There was a change in OwnCloud which rejected this behaviour. You can fix it by changing the trusted_domains config option like so:

Old:

  'trusted_domains' =>
  array (
    0 => '192.168.5.2',
  ),

New

  'trusted_domains' =>
  array (
    0 => '192.168.5.2',
    1 => '192.168.5.2:80',
    2 => '192.168.5.2:443',
  ),

Give it a try.

alavarre commented 9 years ago

Hello, thank you for the input. I tried this but there is no change. I did restart ther Apache2 server and then repeated the actions above: we can find URLs that display the calendar folders and show the .ics file contents in a browser (from both the 'droid and the main machine) but for whatever reason the app fails to load them. We have tried both the version from f-droid and Google PlayStore.

Are there other possible port numbers?

Thank you again. Cheers, Andy

ervee commented 9 years ago

Nope, in your logs it looks like you use default HTTP (port 80). By the way, this port issue should be fixed with the 7.0.4 release of OwnCloud. I updated yesterday and it looks fixed.

But, looks like this is not your problem. I'm sorry.

I truly hope the AndroidCaldavSyncAdapater development is being continued by someone (what's the story on this @Griffon26?). It's the only free CalDav App that works for me and my OwnCloud enviroment... :(

alavarre commented 9 years ago

On Wed, 2014-12-10 at 08:06 -0800, Ralf wrote:

this port issue should be fixed with the 7.0.4 release of OwnCloud. I updated yesterday and it looks fixed.

Woohoo! Yes it is!

I just upgrade OC to 7.0.4 and now it works as it did before.

Well done, thank you.

Cheers, Andy

ervee commented 9 years ago

Great! I'm glad I did mention it ;-) Credits for the fix (and the break...) go to the OC Team off course.

alavarre commented 9 years ago

On Wed, 2014-12-10 at 13:18 -0800, Ralf wrote:

and the break...

:-)

Thanks again. All the best, Andy

alavarre commented 9 years ago

Oh my... A month later and the same problem has returned. It worked last month with the first issue of OC 7.0.4, but now I'm on OC 7.0.4-16.1 and entering the parameters for Android calDAV now responds. Invalid server answer, check URL.

I've checked the trusted_domains config option as above and it is correct.

Thanks in advance, Andy

ervee commented 9 years ago

You should not need to add the ports in the trusted domains config anymore as far as I know. Try removing them. And do you have the exact name you configure in the sync adapter mentioned in the trusted domains config?

alavarre commented 9 years ago

Hello ervee thank you.

I have removed the ports, but it still fails.

How do I enter the "exact name you configure in the sync adapter" into config.php?

The data I enter in the Android sync adapter settings are: • username • password • Account name (optional)

config.php now reads: <?php $CONFIG = array ( 'instanceid' => 'oc1fd9da744f', 'passwordsalt' => '2e191e52aeecaaa057ded162f15227', 'trusted_domains' => array ( 0 => '192.168.5.2', ), 'datadirectory' => '/srv/www/htdocs/owncloud/data', 'dbtype' => 'sqlite3', 'version' => '6.0.3.1', 'installed' => true, );

Where might I study more about how to write config.php?

Thank you again for the prompt response.

Kind regards, Andy

alavarre commented 9 years ago

The URL I am setting in the Android is the one in the settings screen of OC on the PC: Primary CalDAV address gives http://localhost/owncloud/remote.php/caldav/

So I use http://192.168.5.2/owncloud/remote.php/caldav/

which is what worked before. I experimented with various others, none of which worked.

ervee commented 9 years ago

Hi Andy. Your config array looks okay with the URL you use. So I don't know why your OC connection stopped working. There should be documentation on the Owncloud website on how to increase logging and debug this problem. Perhaps the logs can give you a clue...

alavarre commented 9 years ago

Ralf hi.

Problem solved:

.../owncloud/config/config.php

is very particular. In particular, you must list your "Trusted Domains". It is sort of a firewall on top of the main system firewall.

So even if dmesg didn't show any dropped packets, owncloud was doing its own dropping, ignoring calls from domains not listed in config.php.

Adding my LAN network and in particular my main machine solved the problem:

      'trusted_domains' => 
      array (
        0 => 'localhost',
        1 => '192.168.5.0',
        2 => '192.168.5.2',
      ),

Awesome victory. :-)

I find that I do eventually sort out these problems, but sometimes it takes DAYS to do so.

Thank you again for the help.

Kind regards, Andy

On Tue, 2015-01-20 at 13:12 -0800, Ralf wrote:

Hi Andy. Your config array looks okay with the URL you use. So I don't know why your OC connection stopped working. There should be documentation on the Owncloud website on how to increase logging and debug this problem. Perhaps the logs can give you a clue...

— Reply to this email directly or view it on GitHub.

ervee commented 9 years ago

Hi Andy. Great news! Thanks for sharing your solution, it could be helpful to others!