Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Baikal Caldav and Asterisk #1085

Open
mathiasgaertner opened this issue Jan 16, 2022 · 17 comments
Open

Baikal Caldav and Asterisk #1085

mathiasgaertner opened this issue Jan 16, 2022 · 17 comments

Comments

@mathiasgaertner
Copy link

mathiasgaertner commented Jan 16, 2022

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: noreply@www.gr-itexperts.com.au
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

@ByteHamster
Copy link
Member

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?

@mathiasgaertner
Copy link
Author

mathiasgaertner commented Jan 17, 2022

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...

@ByteHamster
Copy link
Member

What php version do you use on your server?

@mathiasgaertner
Copy link
Author

php --version

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

@c0monoid
Copy link

c0monoid commented Feb 5, 2023

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));

@tamtashi
Copy link

tamtashi commented Nov 3, 2023

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?

@purche42
Copy link

purche42 commented Jan 5, 2024

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

@apollo-sturdy
Copy link

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

@nepomuc
Copy link

nepomuc commented Feb 24, 2024

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"?

@apollo-sturdy
Copy link

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

@nepomuc
Copy link

nepomuc commented Feb 27, 2024

@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?

@apollo-sturdy
Copy link

@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?

@nepomuc
Copy link

nepomuc commented Mar 8, 2024

@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 :/

@apollo-sturdy
Copy link

@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!

@nepomuc
Copy link

nepomuc commented Mar 12, 2024

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. 👍

@apollo-sturdy
Copy link

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).

@m-paulus
Copy link

Updating calendarinstances.timezone directly in the database using the example provided by @apollo-sturdy fixed an issue I had been struggling with for a long time. I can now see my Baikal calendars in Home Assistant. Thank you!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants