CalDav Binding is unreliable and causes exceptions from time to time

CalDav binding works very well, in general. But after some time no further updates are downloaded. If I restart the whole openHAB system then, it again is working for some time.

And from time to time I read exceptions in the log file /var/log/openhab2/openhab.log like that:

2019-10-23 12:09:24.761 [WARN ] [caldav.internal.job.EventReloaderJob] - Sardine exception reading ics file: owncloud-38063a5a26a67ef758e87439e3a987db
com.github.sardine.impl.SardineException: Unexpected response
at com.github.sardine.impl.handler.ValidatingResponseHandler.validateResponse(ValidatingResponseHandler.java:48) ~[208:org.openhab.io.caldav:1.13.0]
at com.github.sardine.impl.handler.VoidResponseHandler.handleResponse(VoidResponseHandler.java:34) ~[208:org.openhab.io.caldav:1.13.0]
at com.github.sardine.impl.SardineImpl.get(SardineImpl.java:756) ~[208:org.openhab.io.caldav:1.13.0]
at com.github.sardine.impl.SardineImpl.get(SardineImpl.java:741) ~[208:org.openhab.io.caldav:1.13.0]
at com.github.sardine.impl.SardineImpl.get(SardineImpl.java:732) ~[208:org.openhab.io.caldav:1.13.0]
at com.github.sardine.impl.SardineImpl.get(SardineImpl.java:145) ~[208:org.openhab.io.caldav:1.13.0]
at org.openhab.io.caldav.internal.job.EventReloaderJob.loadEvents(EventReloaderJob.java:318) [208:org.openhab.io.caldav:1.13.0]
at org.openhab.io.caldav.internal.job.EventReloaderJob.execute(EventReloaderJob.java:137) [208:org.openhab.io.caldav:1.13.0]
at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh240]
at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [107:org.eclipse.smarthome.core.scheduler:0.10.0.oh240]

The message refers to a file. And indeed, that file exists at /var/lib/openhab2/etc/caldav/kalendername:

BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.9.5//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
TRANSP:OPAQUE
DTEND;VALUE=DATE:20190117
UID:3ab71c8224
LOCATION:
DTSTAMP:20190116T180838Z
DESCRIPTION:
SEQUENCE:0
CATEGORIES:
SUMMARY:Gelbe Tonne
LAST-MODIFIED:20181228T111031Z
DTSTART;VALUE=DATE:20190116
CREATED:20181228T111031Z
BEGIN:VALARM
X-WR-ALARMUID:7E305012-B513-4B65-AE11-2053D22BBF66
UID:7E305012-B513-4B65-AE11-2053D22BBF66
TRIGGER:-PT15H
ATTACH;VALUE=URI:Basso
ACTION:AUDIO
X-APPLE-DEFAULT-ALARM:TRUE
ACKNOWLEDGED:20190115T211130Z
END:VALARM
BEGIN:VALARM
X-WR-ALARMUID:728FFA99-CFA6-4744-8B51-619B341BE897
UID:728FFA99-CFA6-4744-8B51-619B341BE897
TRIGGER;VALUE=DATE-TIME:20190115T211129Z
ATTACH;VALUE=URI:Basso
ACTION:AUDIO
RELATED-TO:7E305012-B513-4B65-AE11-2053D22BBF66
ACKNOWLEDGED:20190115T211130Z
END:VALARM
END:VEVENT
END:VCALENDAR

I have no glue, what may be wrong with that calendar item. It seems to me quite reasonable. Nothing special.

Has someone an idea?

I hope finding the reason for the exception in the calendar item may lead to the reason, why openHAB stops downloading the calendar.

A new week starts, and may be someone who knows is back from vacation, so I want to push that question.

Meanhwile I sent the calendar event to a site that checks iCalendar files, but it said all is ok. So there also was no hint what causes the exception in CalDav binding.

Unfortunately there was no reply to that topic, but meanwhile I found out by myself, and I want to report for those, who experience the same problem.

There was 1 event per month in the calendar. And the preload time was said to load 14 days ahead. So, after one event passed, the next event was outside the range of the preload time.

I increased the preload time to more than one month. That way, the next event could be loaded before the previous event passed.

After that change of the configuration I experienced no more problems. No freezing any more. All works fine.

So I learned: Set the preload time to a value bigger than the maximum time between 2 successive events.

1 Like

For everybody with similar issues. The solution described in this topic not only works for recurring events, but also for events that span a long time.

I had a similar issue with the CalDav binding throwing loads of exceptions since a couple of weeks, ultimately leading to OpenHab becoming unresponsive.

There was a 6-week event on the family calendar for the summer school holidays and my preloadTime was two weeks.

By increasing the preloadTime to 8 weeks also my issue got solved.

Conclusion: set your preloadTime to a longer period than the longest possible event on your calendar and longer than the longest time between recurring events.