Baikal icon indicating copy to clipboard operation
Baikal copied to clipboard

Baikal Caldav and Asterisk

Open mathiasgaertner opened this issue 3 years ago • 17 comments

Baikal version: 0.9.1

Expected behaviour: Asterisk reads current and upcoming events from calendar

Current behaviour: Error-Message 501 Internal Server error, This parser only supports VCARD and VCALENDAR

Steps to reproduce:

  1. Install Baikal, configure Timezone Australia/Sydney
  2. Create a calendar
  3. Install asterisk 17.5.1 with caldav support, configure a calendar:
[Test]
type=caldav
url=http://www.gr-itexperts.com.au/baikal/html/dav.php/calendars/XXXXX/de-calendar/
user=XXXXX
secret=XXXXXX
refresh=5
timeframe=30
context=calendar
channel=Local/calevent@calendar
extension=start
autoreminder=1
  1. Modify vendor/sabre/vobject/lib/Parser/MimeDir.php:
Line 163:                 throw new ParseException('This parser only supports VCARD and VCALENDAR files: '.$line);
  1. Use tcpdump to sniff packets between asterisk and baikal, i.e. tcpdump -i lo port 80

  2. read return packet from server Screenshot_20220117_102707 Screenshot_20220117_102532

config/baikal.yaml

system:
    configured_version: 0.9.1
    timezone: Australia/Sydney
    card_enabled: true
    cal_enabled: true
    dav_auth_type: Digest
    admin_passwordhash: 707e5f89b02694962575d3be2e24613ff3ae148818489b4293edbeb656aab70a
    failed_access_message: 'user %u authentication failure for Baikal'
    auth_realm: BaikalDAV
    base_uri: ''
    invite_from: [email protected]
database:
    sqlite_file: /srv/www/baikal/Specific/db/db.sqlite
    mysql: true
    mysql_host: database.gr-itexperts.com.au
    mysql_dbname: baikal
    mysql_username: XXXXX
    mysql_password: XXXXX
    encryption_key: XXXXX

The string Australia/Sydney does not appear in any data packet sent from asterisk. Other access to the calendar (thunderbird, android) works fine

mathiasgaertner avatar Jan 16 '22 23:01 mathiasgaertner

You just posted your server url, the hash of the admin password and the salt together. I would strongly recommend changing your password.

Are you using Baikal without https? The dav protocol is unencrypted, so your events/contacts travel in plain text through random WiFi networks that you connect your phone to.

About the actual error: Could you please post the stack trace, which should be printed to your php/Apache/nginx logs?

ByteHamster avatar Jan 17 '22 21:01 ByteHamster

Damnit, I thought I've deleted them. Thank you for the heads up and I changed all PWDs. It is a test environment anyway. And no, I am not using http. This is only to verify what the problem was/is, with https the network trace would be a bit too complex to administer. The working environment is https then. As for the logs. Nothing much in it:

Access-log:

Jan 18 08:39:44 mail root 2403::XXXX - - [18/Jan/2022:08:39:44 +1100] "REPORT /baikal/html/dav.php/calendars/XXXXX/de-calendar/ HTTP/1.1" 500 310 "-" "-"

Error-log:

[Fri Jan 14 11:30:50.049727 2022] [php7:notice] [pid 19808] [client 2403:XXXX:52552] Sabre\\VObject\\ParseException: This parser only supports VCARD and VCALENDAR files in /srv/www/wordpress/baikal/vendor/sabre/vobject/lib/Parser/MimeDir.php:163
Stack trace:
#0 /srv/www/wordpress/baikal/vendor/sabre/vobject/lib/Parser/MimeDir.php(90): Sabre\\VObject\\Parser\\MimeDir->parseDocument()
#1 /srv/www/wordpress/baikal/vendor/sabre/vobject/lib/Reader.php(47): Sabre\\VObject\\Parser\\MimeDir->parse()
#2 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/CalDAV/Plugin.php(513): Sabre\\VObject\\Reader::read()
#3 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/CalDAV/Plugin.php(258): Sabre\\CalDAV\\Plugin->calendarQueryReport()
#4 /srv/www/wordpress/baikal/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\\CalDAV\\Plugin->report()
#5 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/CorePlugin.php(685): Sabre\\DAV\\Server->emit()
#6 /srv/www/wordpress/baikal/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\\DAV\\CorePlugin->httpReport()
#7 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/Server.php(472): Sabre\\DAV\\Server->emit()
#8 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\\DAV\\Server->invokeMethod()
#9 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\\DAV\\Server->start()
#10 /srv/www/wordpress/baikal/Core/Frameworks/Baikal/Core/Server.php(119): Sabre\\DAV\\Server->exec()
#11 /srv/www/wordpress/baikal/html/dav.php(69): Baikal\\Core\\Server->start()
#12 {main}
[Fri Jan 14 11:32:12.358299 2022] [php7:notice] [pid 19805] [client 2403:XXXXX:52656] Sabre\\Xml\\ParseException: The input element to parse is empty. Do not attempt to parse in /srv/www/wordpress/baikal/vendor/sabre/xml/lib/Service.php:122
Stack trace:
#0 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/CorePlugin.php(680): Sabre\\Xml\\Service->parse()
#1 /srv/www/wordpress/baikal/vendor/sabre/event/lib/WildcardEmitterTrait.php(89): Sabre\\DAV\\CorePlugin->httpReport()
#2 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/Server.php(472): Sabre\\DAV\\Server->emit()
#3 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/Server.php(253): Sabre\\DAV\\Server->invokeMethod()
#4 /srv/www/wordpress/baikal/vendor/sabre/dav/lib/DAV/Server.php(321): Sabre\\DAV\\Server->start()
#5 /srv/www/wordpress/baikal/Core/Frameworks/Baikal/Core/Server.php(119): Sabre\\DAV\\Server->exec()
#6 /srv/www/wordpress/baikal/html/dav.php(69): Baikal\\Core\\Server->start()
#7 {main}

I have no idea where the string "Australia/Sydney" is coming from in the input stream. Obviously it is my configured timezone but it is not transferred from ASTERISK to baikal...

mathiasgaertner avatar Jan 17 '22 21:01 mathiasgaertner

What php version do you use on your server?

ByteHamster avatar Jan 23 '22 14:01 ByteHamster

php --version

PHP 7.4.6 (cli) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies

mathiasgaertner avatar Jan 23 '22 21:01 mathiasgaertner

I had a similar error. I don't know why it happens but here is a sloppy workaround:

In Sabre/CalDAV/Plugin on line 513 the function calendarQueryReport() tries to get the timezone via: $vtimezoneObj = VObject\Reader::read($tzResult[$tzProp]); $calendarTimeZone = $vtimezoneObj->VTIMEZONE->getTimeZone(); However for me $tzResult[$tzProp] already contained the timezone. So I replaced the two lines by $calendarTimeZone = new DateTimeZone(print_r($tzResult[$tzProp],true));

c0monoid avatar Feb 05 '23 23:02 c0monoid

Thanks @c0monoid, fixed it with your solution (I changed it at three different functions in that file) - this is still an issue in 0.9.3 - is this release nearly a year old? Anyone going to fix this and create a new release?

tamtashi avatar Nov 03 '23 21:11 tamtashi

This seems to cause a similar problem with Home Assistant integration see https://www-onderka-com.translate.goog/homeassistant-sabre-eod?_x_tr_sl=auto&_x_tr_tl=en&_x_tr_hl=de&_x_tr_pto=wapp

purche42 avatar Jan 05 '24 11:01 purche42

I hade the same issue and noticed that I was not getting the error on calendars that were created by iCal (the MacOS Calendar app). I checked in the Baikal web interface and noticed that for calendars created by iCal the timezone field was set differently than those calendars created by Baikal. So a temporary fix is to recreate your calendar via iCal which is very easy by creating a new calendar in iCal and then right-clicking your old calendar and selecting "Merge" which will delete the old calendar and move all events to the new one.

Opened an issue to fix the problem in Baikal here: https://github.com/sabre-io/Baikal/issues/1241

apollo-sturdy avatar Feb 23 '24 12:02 apollo-sturdy

I hade the same issue and noticed that I was not getting the error on calendars that were created by iCal (the MacOS Calendar app). I checked in the Baikal web interface and noticed that for calendars created by iCal the timezone field was set differently than those calendars created by Baikal. So a temporary fix is to recreate your calendar via iCal which is very easy by creating a new calendar in iCal and then right-clicking your old calendar and selecting "Merge" which will delete the old calendar and move all events to the new one.

Opened an issue to fix the problem in Baikal here: #1241

@apollo-sturdy Can you share an example of what iCal writes to the "cal:calendar-timezone"?

nepomuc avatar Feb 24 '24 02:02 nepomuc

I hade the same issue and noticed that I was not getting the error on calendars that were created by iCal (the MacOS Calendar app). I checked in the Baikal web interface and noticed that for calendars created by iCal the timezone field was set differently than those calendars created by Baikal. So a temporary fix is to recreate your calendar via iCal which is very easy by creating a new calendar in iCal and then right-clicking your old calendar and selecting "Merge" which will delete the old calendar and move all events to the new one. Opened an issue to fix the problem in Baikal here: #1241

@apollo-sturdy Can you share an example of what iCal writes to the "cal:calendar-timezone"?

Sure. Here's an example: BEGIN:VCALENDAR VERSION:2.0 PRODID:-//Apple Inc.//macOS 13.3//EN CALSCALE:GREGORIAN BEGIN:VTIMEZONE TZID:Europe/Zurich BEGIN:DAYLIGHT TZOFFSETFROM:+0100 RRULE:FREQ=YEARLY;BYMONTH=3;BYDAY=-1SU DTSTART:19810329T020000 TZNAME:CEST TZOFFSETTO:+0200 END:DAYLIGHT BEGIN:STANDARD TZOFFSETFROM:+0200 RRULE:FREQ=YEARLY;BYMONTH=10;BYDAY=-1SU DTSTART:19961027T030000 TZNAME:CET TZOFFSETTO:+0100 END:STANDARD END:VTIMEZONE END:VCALENDAR

apollo-sturdy avatar Feb 25 '24 17:02 apollo-sturdy

@apollo-sturdy Thanks a lot. I put it into the database manually and it also shows up when visiting my Baikal calendar's url in the browser: image But it didn't change anything regarding cal.com's availability check. cal.com still cannot pull my calendar items. :/ Or did I do something wrong when pasting it into Baikal's database?

nepomuc avatar Feb 27 '24 10:02 nepomuc

@apollo-sturdy Thanks a lot. I put it into the database manually and it also shows up when visiting my Baikal calendar's url in the browser: image But it didn't change anything regarding cal.com's availability check. cal.com still cannot pull my calendar items. :/ Or did I do something wrong when pasting it into Baikal's database?

Hmm in that case I'm not sure. Maybe you have a separate issue going on. Have you checked baikal and calcoms logs?

apollo-sturdy avatar Feb 27 '24 19:02 apollo-sturdy

@apollo-sturdy Couldn't find any useful logs from Baikal (only that REPORT requests where received) and for my cal.com setup i found weird debug outputs like

@calcom/web:start: 00:14:14:307 DEBUGgetUserAvailability Using schedule: {"chosenSchedule":{"availability":[{"date":null,"startTime":"1970-01-01T09:00:00.000Z","endTime":"1970-01-01T18:00:00.000Z","days":[1,2,3,4,5]}],"timeZone":"Europe/Berlin","id":1},"userSchedule":{"availability":[{"date":null,"startTime":"1970-01-01T09:00:00.000Z","endTime":"1970-01-01T18:00:00.000Z","days":[1,2,3,4,5]}],"timeZone":"Europe/Berlin","id":1}}

I use completely unmodified versions of Baikal and cal.com though. So there should be nothing special about my setup. Any suggestions or ideas? Baikal is officially listed by cal.com to work together and they don't :/

nepomuc avatar Mar 08 '24 00:03 nepomuc

@apollo-sturdy Couldn't find any useful logs from Baikal (only that REPORT requests where received) and for my cal.com setup i found weird debug outputs like

@calcom/web:start: 00:14:14:307 DEBUGgetUserAvailability Using schedule: {"chosenSchedule":{"availability":[{"date":null,"startTime":"1970-01-01T09:00:00.000Z","endTime":"1970-01-01T18:00:00.000Z","days":[1,2,3,4,5]}],"timeZone":"Europe/Berlin","id":1},"userSchedule":{"availability":[{"date":null,"startTime":"1970-01-01T09:00:00.000Z","endTime":"1970-01-01T18:00:00.000Z","days":[1,2,3,4,5]}],"timeZone":"Europe/Berlin","id":1}}

I use completely unmodified versions of Baikal and cal.com though. So there should be nothing special about my setup. Any suggestions or ideas? Baikal is officially listed by cal.com to work together and they don't :/

For what it's worth I'm running this docker image of baikal and cal.com both via Tipi. Not really sure how else to help. Sorry!

apollo-sturdy avatar Mar 08 '24 08:03 apollo-sturdy

For what it's worth I'm running this docker image of baikal and cal.com both via Tipi. Not really sure how else to help. Sorry!

Thanks, I installed the docker version of Baikal and completely reinstalled the docker version of cal.com but the problem still exists. Can you tell me which versions of Baikal and cal.com you use. There obviously is a combination that actually works. 👍

nepomuc avatar Mar 12 '24 11:03 nepomuc

For what it's worth I'm running this docker image of baikal and cal.com both via Tipi. Not really sure how else to help. Sorry!

Thanks, I installed the docker version of Baikal and completely reinstalled the docker version of cal.com but the problem still exists. Can you tell me which versions of Baikal and cal.com you use. There obviously is a combination that actually works. 👍

Hey. I'm using the latest versions from tipi, so would be: https://github.com/runtipi/runtipi-appstore/blob/master/apps/baikal/docker-compose.yml#L5 (ckulka/baikal:0.9.4-nginx) https://github.com/runtipi/runtipi-appstore/blob/master/apps/calcom/docker-compose.yml (calcom/cal.com:v3.8.7).

apollo-sturdy avatar Mar 12 '24 14:03 apollo-sturdy