Roon doesn't remember enabled extension

(Rob Anderson) #1

Hi

I’m playing around with https://github.com/st0g1e/roon-extension-http-api

It works fine once I have enabled it in the Roon > Settings > Extensions dialog.

However, if I quit and restart Roon, it stops working. If I go back to the Roon > Settings > Extensions dialog again I can see it discovered as a new extension (with the same name). Viewing already enabled extensions shows the original still enabled. Enabling the new version makes it work again. So then I have two identical entries in the already enabled extensions box.

The same behaviour occurs if I close my laptop and re-open it.

So can anyone help me understand how Roon identifies discovered extensions as unique? Anything I can do to fix this?

Thanks

Rob

(Ben) #2

The general mechanism works like this:

  1. When the user enables the extension in the settings page in Roon, Roon sends a random “token” string to the extension.
  2. The extension saves the token string, and sends it to Roon the next time it is restarted.
  3. If Roon sees a token it remembers being authorized it trusts that extension and doesn’t show the enable button.

My best guess is that the http-api extension isn’t saving the token value, or perhaps isn’t resending it correctly. I’m not sure how helpful that is exactly, just trying to get back into the habit of responding here when I can.

(Rob Anderson) #3

Hi Ben

Thanks for explaining - makes perfect sense. I will dig into the extension and debug what is going wrong!

Rob

(Rob Anderson) #4

This problem is now resolved for me. In case anyone else has the same symptoms, here’s what I found / did.

I’m on a Mac. I’m running Roon core locally.

I had installed the roon-extension-http-api into /Users/me/roon/roon-extension-http-api/

After firing up node to run the extension, a file called config.json appeared in this directory, which (confusingly to me, at least) seems to be written by Roon itself, not by the extension. It contains the magic token.

Subsequently restarting the extension and/or Roon worked fine - the token persisted and the extension was remembered by Roon.

In order to launch the extension automatically on boot, I had created a Mac launch agent. This didn’t “remember” extension authorisations at first, because (it transpired) Roon couldn’t find the config.json file. Adding a WorkingDirectory key to the launch agent plist fixes the issue.

Now sending GET requests to localhost:3001 allows me to control Roon. I am using Alfred to bind hotkeys to curl requests for volume up, volume down and play/pause, which now work globally (ie, no matter what app has focus).

My plist for the service is below.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>Label</key><string>reha</string>
      <key>ProgramArguments</key>
      <array>
        <string>/usr/local/bin/node</string>
        <string>/Users/me/roon/roon-extension-http-api</string>
      </array>
      <key>KeepAlive</key><true/>
      <key>NetworkState</key><true/>
      <key>StandardErrorPath</key><string>/Users/me/roon/launchagent.log</string>
      <key>StandardOutPath</key><string>/Users/me/roon/launchagent.log</string>
      <key>WorkingDirectory</key> <string>/Users/me/roon/roon-extension-http-api</string>
      <key>LaunchOnlyOnce</key><true/>
    </dict>
  </plist>

Thanks again to Ben for pointing me in the right direction.

(Ben) #5

For reference, that file is written by the library we wrote for node.js code to interface with the Roon API. It’s technically part of the extension, in that it lives in the extension code, but it’s a couple layers away from what people normally think of as “an extension” that they might write or ship to someone.