Opcua node crawler method giving me an array of 745 items. But I can only see around 25 items when I look at ua expert.
My current code:
const client = opcua.OPCUAClient.create(connectionOption);
await client.connect(url);
const session = await client.createSession(userIdentity);
const items = [];
var crawler = new NodeCrawler(session);
crawler.on("browsed", function (element) {
if (element.nodeClass === 2) {// 2 means variable type
const nodeId = new opcua.NodeId(element.nodeId.identifierType, element.nodeId.value, element.nodeId.namespace);
const nodeIdString = nodeId.toString();
items.push(nodeIdString);
}
});
await crawler.read(nodeId);
How can I get the same result as UaExpert?
My code result:
UaExpert:
Nodes which are not shown in UaExpert but exits in crawler result:
Node details which is not shown in UaExpert
{
description: null,
nodeId: 'ns=0;i=11574',
browseName: { namespaceIndex: 0, name: 'MaxMonitoredItemsPerCall' },
references: [
{
referenceTypeId: 'ns=0;i=37',
isForward: true,
nodeId: 'ns=0;i=80',
browseName: { namespaceIndex: 0, name: 'Optional' },
displayName: { text: 'Optional' },
nodeClass: 'Object',
typeDefinition: 'ns=0;i=77',
},
{
referenceTypeId: 'ns=0;i=40',
isForward: true,
nodeId: 'ns=0;i=68',
browseName: { namespaceIndex: 0, name: 'PropertyType' },
displayName: { text: 'PropertyType' },
nodeClass: 'VariableType',
typeDefinition: 'ns=0;i=0',
},
],
nodeClass: 2,
typeDefinition: 'ns=0;i=68',
displayName: { text: 'MaxMonitoredItemsPerCall' },
parent: {
description: null,
nodeId: 'ns=0;i=11564',
browseName: { namespaceIndex: 0, name: 'OperationLimitsType' },
references: [
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11574',
browseName: { namespaceIndex: 0, name: 'MaxMonitoredItemsPerCall' },
displayName: { text: 'MaxMonitoredItemsPerCall' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11570',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerBrowse' },
displayName: { text: 'MaxNodesPerBrowse' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12161',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryReadData' },
displayName: { text: 'MaxNodesPerHistoryReadData' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12162',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryReadEvents' },
displayName: { text: 'MaxNodesPerHistoryReadEvents' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12163',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryUpdateData' },
displayName: { text: 'MaxNodesPerHistoryUpdateData' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=12164',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerHistoryUpdateEvents' },
displayName: { text: 'MaxNodesPerHistoryUpdateEvents' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11569',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerMethodCall' },
displayName: { text: 'MaxNodesPerMethodCall' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11573',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerNodeManagement' },
displayName: { text: 'MaxNodesPerNodeManagement' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11565',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerRead' },
displayName: { text: 'MaxNodesPerRead' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11571',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerRegisterNodes' },
displayName: { text: 'MaxNodesPerRegisterNodes' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11572',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerTranslateBrowsePathsToNodeIds' },
displayName: { text: 'MaxNodesPerTranslateBrowsePathsToNodeIds' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
{
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11567',
browseName: { namespaceIndex: 0, name: 'MaxNodesPerWrite' },
displayName: { text: 'MaxNodesPerWrite' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
],
nodeClass: 8,
typeDefinition: 'ns=0;i=0',
displayName: { text: 'OperationLimitsType' },
parent: {
description: null,
nodeId: 'ns=0;i=61',
browseName: { namespaceIndex: 0, name: 'FolderType' },
references: [
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=16405',
browseName: { namespaceIndex: 0, name: 'AlarmGroupType' },
displayName: { text: 'AlarmGroupType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=23456',
browseName: { namespaceIndex: 0, name: 'AliasNameCategoryType' },
displayName: { text: 'AliasNameCategoryType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=23556',
browseName: { namespaceIndex: 0, name: 'AuthorizationServicesConfigurationFolderType' },
displayName: { text: 'AuthorizationServicesConfigurationFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=13813',
browseName: { namespaceIndex: 0, name: 'CertificateGroupFolderType' },
displayName: { text: 'CertificateGroupFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=17591',
browseName: { namespaceIndex: 0, name: 'DictionaryFolderType' },
displayName: { text: 'DictionaryFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=13353',
browseName: { namespaceIndex: 0, name: 'FileDirectoryType' },
displayName: { text: 'FileDirectoryType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=17496',
browseName: { namespaceIndex: 0, name: 'KeyCredentialConfigurationFolderType' },
displayName: { text: 'KeyCredentialConfigurationFolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=11564',
browseName: { namespaceIndex: 0, name: 'OperationLimitsType' },
displayName: { text: 'OperationLimitsType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=2;i=1005',
browseName: { namespaceIndex: 2, name: 'FunctionalGroupType' },
displayName: { text: 'FunctionalGroupType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
],
typeDefinition: 'ns=0;i=0',
displayName: { text: 'FolderType' },
parent: {
description: null,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar',
browseName: { namespaceIndex: 4, name: 'Scalar' },
references: [
{
referenceTypeId: 'ns=0;i=40',
isForward: true,
nodeId: 'ns=0;i=61',
browseName: { namespaceIndex: 0, name: 'FolderType' },
displayName: { text: 'FolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Boolean',
browseName: { namespaceIndex: 4, name: 'Boolean' },
displayName: { text: 'Boolean' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Byte',
browseName: { namespaceIndex: 4, name: 'Byte' },
displayName: { text: 'Byte' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.ByteString',
browseName: { namespaceIndex: 4, name: 'ByteString' },
displayName: { text: 'ByteString' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.DateTime',
browseName: { namespaceIndex: 4, name: 'DateTime' },
displayName: { text: 'DateTime' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Double',
browseName: { namespaceIndex: 4, name: 'Double' },
displayName: { text: 'Double' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.ExpandedNodeId',
browseName: { namespaceIndex: 4, name: 'ExpandedNodeId' },
displayName: { text: 'ExpandedNodeId' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Float',
browseName: { namespaceIndex: 4, name: 'Float' },
displayName: { text: 'Float' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Guid',
browseName: { namespaceIndex: 4, name: 'Guid' },
displayName: { text: 'Guid' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.ImageGIF',
browseName: { namespaceIndex: 4, name: 'ImageGIF' },
displayName: { text: 'ImageGIF' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Int16',
browseName: { namespaceIndex: 4, name: 'Int16' },
displayName: { text: 'Int16' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Int32',
browseName: { namespaceIndex: 4, name: 'Int32' },
displayName: { text: 'Int32' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Int64',
browseName: { namespaceIndex: 4, name: 'Int64' },
displayName: { text: 'Int64' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.LocalizedText',
browseName: { namespaceIndex: 4, name: 'LocalizedText' },
displayName: { text: 'LocalizedText' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.NodeId',
browseName: { namespaceIndex: 4, name: 'NodeId' },
displayName: { text: 'NodeId' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.QualifiedName',
browseName: { namespaceIndex: 4, name: 'QualifiedName' },
displayName: { text: 'QualifiedName' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Quality_DynamicValue',
browseName: { namespaceIndex: 4, name: 'Quality_DynamicValue' },
displayName: { text: 'Quality_DynamicValue' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.Quality_StaticValue',
browseName: { namespaceIndex: 4, name: 'Quality_StaticValue' },
displayName: { text: 'Quality_StaticValue' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.SByte',
browseName: { namespaceIndex: 4, name: 'SByte' },
displayName: { text: 'SByte' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.StatusCode',
browseName: { namespaceIndex: 4, name: 'StatusCode' },
displayName: { text: 'StatusCode' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.String',
browseName: { namespaceIndex: 4, name: 'String' },
displayName: { text: 'String' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.UInt16',
browseName: { namespaceIndex: 4, name: 'UInt16' },
displayName: { text: 'UInt16' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.UInt32',
browseName: { namespaceIndex: 4, name: 'UInt32' },
displayName: { text: 'UInt32' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.UInt64',
browseName: { namespaceIndex: 4, name: 'UInt64' },
displayName: { text: 'UInt64' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
{
referenceTypeId: 'ns=0;i=35',
isForward: true,
nodeId: 'ns=4;s=Demo.Dynamic.Scalar.XmlElement',
browseName: { namespaceIndex: 4, name: 'XmlElement' },
displayName: { text: 'XmlElement' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=63',
},
],
nodeClass: 1,
typeDefinition: 'ns=0;i=61',
displayName: { text: 'Scalar' },
},
referenceToParent: {
referenceTypeId: 'ns=0;i=40',
isForward: true,
nodeId: 'ns=0;i=61',
browseName: { namespaceIndex: 0, name: 'FolderType' },
displayName: { text: 'FolderType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
},
referenceToParent: {
referenceTypeId: 'ns=0;i=45',
isForward: true,
nodeId: 'ns=0;i=11564',
browseName: { namespaceIndex: 0, name: 'OperationLimitsType' },
displayName: { text: 'OperationLimitsType' },
nodeClass: 'ObjectType',
typeDefinition: 'ns=0;i=0',
},
},
referenceToParent: {
referenceTypeId: 'ns=0;i=46',
isForward: true,
nodeId: 'ns=0;i=11574',
browseName: { namespaceIndex: 0, name: 'MaxMonitoredItemsPerCall' },
displayName: { text: 'MaxMonitoredItemsPerCall' },
nodeClass: 'Variable',
typeDefinition: 'ns=0;i=68',
},
dataType: 'ns=0;i=7',
dataValue: {
value: { dataType: 'Null', arrayType: 'Scalar' },
statusCode: { value: 0 },
sourceTimestamp: '2022-12-29T15:48:59.598Z',
sourcePicoseconds: 801300000,
serverTimestamp: '2022-12-29T15:48:59.598Z',
serverPicoseconds: 801300000,
},
valueRank: -1,
minimumSamplingInterval: 50,
accessLevel: 1,
userAccessLevel: 1,
};
If you want to filter the results, you can do it by accessLevel attribute. In my case all of the nodes I want to see in crawler result have accessLevel:3.
Simply changing this line
from (element.nodeClass === 2)
to (element.nodeClass === 2 && element.accessLevel === 3)
worked for me.