{"id":1234,"date":"2022-06-15T00:43:06","date_gmt":"2022-06-15T04:43:06","guid":{"rendered":"http:\/\/www.rfdm.com\/blog\/?p=1234"},"modified":"2022-06-15T00:43:06","modified_gmt":"2022-06-15T04:43:06","slug":"mcrover-now-monitors-plex-server","status":"publish","type":"post","link":"https:\/\/www.rfdm.com\/blog\/?p=1234","title":{"rendered":"mcrover now monitors Plex server"},"content":{"rendered":"<p>mcrover is now monitoring my Plex server.<br \/>\nThis was more work than expected.  A big part of the issue here is that the REST API uses XML.  I&#8217;ve always disliked using XML.  It&#8217;s a nice technology, but when it comes to open source libraries for C++, it&#8217;s always been lacking.<\/p>\n<p>Long ago, I used Xerces.  Not because it&#8217;s the best, but because it was the only liberally licensed library with support for DTD and Schema validation.  That is still the case today.  Unfortunately, it&#8217;s very cumbersome to use and is written in old C++ (as in C++ 1998).  There&#8217;s a lot of boilerplate, a considerable amount of global state (very bad for multithreaded applications), and a lot of the memory management is left to the application.  I can&#8217;t imagine anyone today is using it in production.<\/p>\n<p>But I plunged ahead anyway.  Sadly, it was a mistake.  Somewhere it was stomping on the stack, often in ways that caused problems deep inside openssl (which I don&#8217;t use directly, instead using boost::beast and boost::certify).  The stack corruption caused problems trying to debug, and I didn&#8217;t have the time to figure it out.  And of course I&#8217;m always suspicious of openssl, given the fact that it&#8217;s written in C and many of us lived through Heartbleed and many other critical openssl vulnerabilities.  To be honest, we&#8217;ve been in desperate need of a really good, modern (and in at least C++11) C++ implementation of TLS for more than a decade.  Of course I could rant about our whole TLS mess for hours, but I&#8217;ll spare you.<\/p>\n<p>Time being of the essence, I switched to pugixml.  I don&#8217;t need DTD\/Schema validation.  Problem gone, a lot less code, and a much more modern API (much harder to shoot yourself in the foot).<\/p>\n<p>Inside mcrover, I&#8217;m using XPath on the XML returned by Plex.  The internal code is generic; it would not be much work to support other Web applications with XML interfaces.  The XPath I look for in the XML is a configuration item, and really the only reason I have something specific for Plex is their use of an API token.  But the configuration is generic enough that supporting other XML Web applications shouldn&#8217;t be difficult.<\/p>\n<p>At any rate, what I have now works.  So now I don&#8217;t get blackholed fixing a Plex issue when I haven&#8217;t used it for months and something has gone wrong.  I know ahead of time.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mcrover is now monitoring my Plex server. This was more work than expected. A big part of the issue here is that the REST API uses XML. I&#8217;ve always disliked using XML. It&#8217;s a nice technology, but when it comes to open source libraries for C++, it&#8217;s always been lacking. Long ago, I used Xerces. &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.rfdm.com\/blog\/?p=1234\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;mcrover now monitors Plex server&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[29,12],"tags":[],"class_list":["post-1234","post","type-post","status-publish","format-standard","hentry","category-freebsd","category-software-development"],"_links":{"self":[{"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1234","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1234"}],"version-history":[{"count":1,"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1234\/revisions"}],"predecessor-version":[{"id":1235,"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/1234\/revisions\/1235"}],"wp:attachment":[{"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1234"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1234"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.rfdm.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1234"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}