Pairing Core functionality issue

Hi guys,

RoPieee uses the Roon API to interact with Roon for those users that have the touchscreen connected. Recently I’m getting reports of strange behavior and I’ve been searching in my extension. And I’m seeing some things that I can’t explain. I really hope this is just me being very stupid, but I think the extension is not behaving like it should be wrt pairing functionality.

To make it easier to discuss this I took the example from Roon’s github page. One change: for (my) clarity’s sake I’ve put what’s happening in the ‘on_pair’ callback in a separate function.

If I run the extension with a single core everything is working as expected. As soon as I introduce another core thinks do not work as I expect.

So here’s the scenario:

  • start the extension with 1 running core
  • enable the extension
  • core_paired is being called
  • start playing some content
  • extension shows continuous updates
  • start a second core
  • enable the extension
  • pair the extension

And here the confusion starts. Upon pairing the extension on the second core I would expect first that the ‘core_paired’ function is called and obviously the ‘core_unpaired’ is being called from the first core.

But nothing of that is happening. So what you see is that the core is being paired to the second core, but information is coming still from the first core!

So either I don’t understand how the pairing functionality is working… or something is broken. Would love some feedback on this!

// vim:ft=javascript:ts=3:sw=3:sts=3:et
"use strict";

var core;
var transport;

var RoonApi          = require("node-roon-api"),
    RoonApiStatus    = require("node-roon-api-status"),
    RoonApiTransport = require("node-roon-api-transport");

var roon = new RoonApi({
    extension_id:        'com.elvis.test',
    display_name:        "Elvis's First Roon API Test",
    display_version:     "1.0.0",
    publisher:           'Elvis Presley',
    email:               'elvis@presley.com',
    website:             'https://github.com/elvispresley/roon-extension-test',

    core_paired: function(_core) {
        console.log("CORE_PAIRED: " + _core.display_name);
        core = _core;
        transport = core.services.RoonApiTransport;
        transport.subscribe_zones(subscribe_zones);
    },

    core_unpaired: function(_core) {
                   console.log("CORE_UNPAIRED: " +_core.core_id,
                               _core.display_name,
                               _core.display_version,
                               "-",
                               "LOST");
    }
});

var svc_status = new RoonApiStatus(roon);

roon.init_services({
    required_services: [ RoonApiTransport ],
    provided_services: [ svc_status ],
});

svc_status.set_status("All is good", false);

roon.start_discovery();

// let's see what Roon got for us
function subscribe_zones(cmd, data) {
   console.log(core.core_id,
               core.display_name,
          core.display_version,
          "-",
          cmd,
          JSON.stringify(data, null, '  '));
}

Regards Harry

Not sure about multi-core as I havnt setup two cores.

In my core-unpaired handler for Deep Harmony I have
setTimeout(() => this.restart(), 1000);

Where this.restart() is a function in my code that cleans up state and calls roon’s start_discovery() method.
This seems to help speed up re-pairing as otherwise it can take up to 20 seconds or so.

However what I am seeing with your extension right now is as follows:
Start with it removed.
Restart your extension your web admin advanced page
It now appears in Roon setttings as expected with ‘enable’ button.
Click the enable button and now your extension disappears.
I assume some process exception that caused an exit, and then I assume it auto-restarts about a second or so later; at which time…
Your extension repears in Roon settings very briefly and disappears again for the cycle too repeat indefinitely.

I did go into the image via SSH, but as ls, cd etc seems non functional, I could not navigate to anywhere useful - like locate and delete config.json. If you can tell me where that is (full path), then I can try deleting it and see if that helps. If there are any log you want my to extract, let me know where they are and I dig them out.

BTW - thanks for maintaining this image - great addition to Roon :+1:

On a separate thing, I would like to have an offline conversation with you about Deep Harmony and things I have in mind for it in the future that may be a very good fit for a Ropieee type image.

Can someone from the @support comment on this? Am i misinterpreting how pairing is supposed to work?

Your understanding seems right to me, which suggests that something may be wrong. Comments @danny, @ben ?

@Jan_Koudijs, you had a possible extension issue as well?

I’ve had this test running for some time and I also noticed a crash. Can’t reproduce it (yet). To be continued.

In my Extension Manager I print a message if the core_unpaired callback gets called and I received a log file from a user in which the unpaired message occurs quite regularly. This made me wonder if these unpairs are also the cause of the RoPieee extension problem where it no longer receives updates.

Thanks for the simple extension demonstrating the problem, that helped a lot.

I have this reproducing locally, and think I understand the problem as a bug in our node-roon-api library. I looks to me like core_paired/core_unpaired are called when Roon cores are started/stopped but not when pairing is changed.

I have mostly untested/unreviewed fix here: https://github.com/RoonLabs/node-roon-api/tree/fix-core_paired

@spockfish, can you try that and let me know if it seems to work?

1 Like

Hi Ben,

Thanks for looking into this. I’ve tested your version rather extensively and to me it seems like a solid ‘solved’ :slight_smile:

So… what’s the next step? Can I use this or should I wait for a formal release?

Thanks!

4 posts were split to a new topic: JS Extension crash after suspend