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

Subscribe to value changes #26

Open
Nico96R opened this issue Nov 26, 2022 · 14 comments
Open

Subscribe to value changes #26

Nico96R opened this issue Nov 26, 2022 · 14 comments
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@Nico96R
Copy link

Nico96R commented Nov 26, 2022

I've experienced a problem with the subscription to a specific node with a leaf. I've use the following code, slightly adapted from your example.

I do get the node and its child leaf, but when I change the value of the leaf I do not get an update. Am I doing something wrong or is there an error in the implementation. Most likely I'm wrong and forgot something.
I've had the same results on the user labels of Lawos PowerCore Sources and on Matrix Labels by Riedels Mediornet.
On the Riedel Matrizes the following code worked perfectly.
Looking forward to your solution.

import {EmberClient} from "emberplus-connection";
import {FieldFlags} from "emberplus-connection/dist/model/Command";

const client = new EmberClient(IP, 9000);

const initember = async (): Promise<any> => {
    client.on("error", e => {
        console.log(e);
    });
    await client.connect()
// Get Root info
    const req = await client.getDirectory(client.tree)

    return await req.response
}

const testMethod = async (path: string): Promise<any> => {

    const testNode = await client.getElementByPath(path).then(async (node) => {
        console.log("Get Node: \n")
        console.log(await node)
        return (
          await client.getDirectory(await node, FieldFlags.All, (update) => {
                console.log(update)
            }
          )
        ).response
    }).catch(() => console.log(path + ": Node does not exist."))
    return testNode
}

//Riedels Matrix label
initember().then((x) =>
    testMethod("1.2.0.1.1.0").then((x => console.log(x))))
@mint-dewit
Copy link

Hi,

I've tried to reproduce against the provider from this library but await client.getElementByPath('1.1.1', (v) => console.log(v.contents.value)) works perfectly fine for me. AfaIk we also use subscriptions in production with a lawo mc2 and a powercore.

Can you provide a pcap file with the socket communication?

@Nico96R
Copy link
Author

Nico96R commented Nov 28, 2022

Thanks for the tip with the callback on a specific leaf with the getElementByPath function. That worked for PowerCore, unfortunately not on Riedels Mediornet. I can send a pcap file on Thursday.

@Nico96R
Copy link
Author

Nico96R commented Dec 1, 2022

I captured the traffic to the "Riedel MicroN" with wireshark. Hopefully that might help you solve my problem.
I still get no updates on value changes
Ember-Communication-Riedel-Mediornet.pcapng.zip

@Nico96R Nico96R closed this as completed Dec 1, 2022
@Nico96R Nico96R reopened this Dec 1, 2022
@Nico96R
Copy link
Author

Nico96R commented Dec 1, 2022

I also caputured the Traffic to "Lawo's PowerCore". The callback in this case works.
The used source code now implements your (@baltedewit) recommendation.

import {EmberClient} from "emberplus-connection";

const client = new EmberClient("10.20.33.62", 9001);

const initember = async (): Promise<any> => {
    client.on("error", e => {
        console.log(e);
    });
    await client.connect()
// Get Root info
    const req = await client.getDirectory(client.tree)

    return await req.response
}

const testMethod = async (path: string): Promise<any> => {

    return await client.getElementByPath(path, (v) => console.log("value" in v.contents ? v.contents.value :"not existent"))
}

// Get user label 1 of Source
initember().then(() =>
  testMethod("1.1.2.9.1.1").then((x => console.log(x))))

Ember-Communication-Lawo-Powercore.pcapng.zip

@Nico96R
Copy link
Author

Nico96R commented Dec 9, 2022

@baltedewit did my provided pcap files help you find my error? If not i can try to produce another one. Thanks a lot!

@Nico96R
Copy link
Author

Nico96R commented Dec 14, 2022

Made further tests with the original Lawo implementation in C. There does the GetDirectory work for value changes of the labels.

@Nico96R
Copy link
Author

Nico96R commented Dec 14, 2022

And I still have troubles querying the PowerCore Matrix. I get the following error:
error.txt
used this source code:

import {EmberClient} from "emberplus-connection";

const client = new EmberClient("10.20.33.62", 9001);

const initember = async (): Promise<any> => {
    client.on("error", e => {
        console.log(e);
    });
    await client.connect()
// Get Root info
    const req = await client.getDirectory(client.tree)

    return await req.response
}

const testMethod = async (path: string): Promise<any> => {

    return await client.getElementByPath(path, (v) => console.log(v)).then( node => {
        client.subscribe(node, n => console.log(n))
    })
}

//Path to PowerCore Matrix
initember().then(() =>
  testMethod("1.3.1").then((x => console.log(x))))

could you verify this behavior in your environment?

@mint-dewit
Copy link

mint-dewit commented Apr 14, 2023

Sorry, I haven't been able to look at this yet. Hopefully soon! There has been some changes in the master regarding communication with the riedel stuff on the master branch, perhaps these may be related?

@boristian
Copy link

Hi, with a build from latest master i am getting the same error when trying to access a matrix node on a DHD device:

Error (InvalidAsn1Error]: Expected Oxa0: got 0x0
at newInvalidAsn1Error (/.../node_modules/asni/lib/ber/errors.js:7:13)
at Reader. readSequence (/.../node_modules/asn1/lib/ber/reader.js:188:11)
at decodeMatrixContents (/.../node_modules/emberplus-connection/dist/encodings/ber/decoder/Matrix.js:142:28)
at decodeMatrix (/.../node_modules/emberplus-connection/dist/encodings/ber/decoder/Matrix.js:36:61)
at decodeGenericElement (/.../node_modules/emberplus-connection/dist/encodings/ber/decoder/Tree.js:46:42)
at decodeRootElements (/.../node_modules/emberplus-connection/dist/encodings/ber/decoder/Tree.js:164:24.
at berDecode (/.../node_modules/emberplus-connection/dist/encodings/ber/index.js:59:52)
at S101Codec.<anonymous> (/.../node_modules/emberplus-connection/dist/Ember/Socket/S101Socket.js:32:48)
at S101Codec.emit (node: events: 513:28)
at S101Codec.handleEmberPacket (/.../node_modules /emberplus-connection/dist/S101/S101Codec.js:151:14)

@Nico96R
Copy link
Author

Nico96R commented Nov 28, 2023

i have the same problem with LAWO vpro8, Riedel micron and still with LAWO PowerCore

@mint-dewit
Copy link

@Nico96R is the error you're seeing the same as with the DHD device? (i.e. Expected 0xa0: got 0x0)

NRK is not currently using subscriptions on matrices so that explains why we haven't seen this. I'm not sure if I can get this prioritised, and I'm also not very familiar with the workings of the asn1 library we use so I'm not sure how hard it is to fix.

@Nico96R
Copy link
Author

Nico96R commented Nov 29, 2023

Yes it is the same error. The error hasn’t changed since last year.

And I still have troubles querying the PowerCore Matrix. I get the following error: error.txt used this source code:

import {EmberClient} from "emberplus-connection";

const client = new EmberClient("10.20.33.62", 9001);

const initember = async (): Promise<any> => {
    client.on("error", e => {
        console.log(e);
    });
    await client.connect()
// Get Root info
    const req = await client.getDirectory(client.tree)

    return await req.response
}

const testMethod = async (path: string): Promise<any> => {

    return await client.getElementByPath(path, (v) => console.log(v)).then( node => {
        client.subscribe(node, n => console.log(n))
    })
}

//Path to PowerCore Matrix
initember().then(() =>
  testMethod("1.3.1").then((x => console.log(x))))

could you verify this behavior in your environment?

@mint-dewit mint-dewit added bug Something isn't working help wanted Extra attention is needed labels Dec 5, 2023
@mint-dewit
Copy link

Unfortunately NRK currently does not have the capacity to look at this issue further, as always we are more than happy to accept pull requests regarding this issue.

@lukirs95
Copy link

lukirs95 commented Jul 26, 2024

I think #39 should fix this problem. It did for me.
The problem is, that the current release doesn't send the "Get Directory" request down until the parameter. It only requests the parent of the of the last given path element.

If you requested path "1.2.3.4.5" and 5 is the parameter, the last "getDirectory()" was for node 4 instead of 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants