- Saved searches
- Use saved searches to filter your results more quickly
- License
- HBM/opcua
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- Learn how to use
- Creating a simple Client
- Creating a virtual Weather Station OPC/UA Server
- Creating a HTML Dashboard to monitor a
- Saved searches
- Use saved searches to filter your results more quickly
- mrxdst/opc-ua
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
- Saved searches
- Use saved searches to filter your results more quickly
- iliareshetov/node-opcua-client
- Name already in use
- Sign In Required
- Launching GitHub Desktop
- Launching GitHub Desktop
- Launching Xcode
- Launching Visual Studio Code
- Latest commit
- Git stats
- Files
- README.md
- About
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
TypeScript / JavaScript OPC UA client for the browser
License
HBM/opcua
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
TypeScript / JavaScript OPC UA client for the browser.
import Client from 'opcua' const client = new Client('ws://localhost:1234') // open socket connection await client.open() // send hello and wait for acknowledge const ack = await client.hello() // open secure channel const openSecureChannelResponse = await client.openSecureChannel() // create session const createSessionResponse = await client.createSession() // activate session const activateSessionResponse = await client.activateSession() // browse root folder const req = new BrowseRequest( NodesToBrowse: [ new BrowseDescription( NodeId: NewTwoByteNodeId(IdRootFolder), BrowseDirection: BrowseDirectionBoth, IncludeSubtypes: true, ResultMask: BrowseResultMaskAll >) ] >) const res = await client.browse(req) for (const result of res.Results as BrowseResult[]) for (const ref of result.References as ReferenceDescription[]) console.log(ref.DisplayName.Text) > >
. work in progress . it’s pretty complex so we need some diagrams
The source code is written in TypeScript. We use the TypeScript compiler to create the JavaScript files for the browser.
Some source code files are autogenerated.
- src/ua/generated.ts by cmd/service/main.go
- src/id/id.ts by cmd/id/main.go
- src/ua/StatusCode.ts by cmd/status/main.go
Do not edit them by hand. You need Go on your machine to execute those generators. The schema definition files are located at ./schema .
We rely on reflection and decorators to get types (e.g. uint32 , CreateSessionRequest or arrays of certain types string[] ) during runtime. In JavaScript a number is always double-precision 64-bit. OPC UA has much more number types like int8 , uint8 , int16 , uint16 and so on. In order to get the binary encoding / decoding right we must know exactly how many bits represent a number.
The client architecture consists of multiple layers. They closely follow the official OPC UA specification. Read the following diagram from bottom to top. On the right side you find the responsibilities for each layer.
The OPC UA handshake is quite complex and several steps are necessary to get an active session. Those steps are
- Hello / Acknowledge
- Open Secure Channel
- Create Session
- Activate Session
The following diagram shows this sequence and highlights response parameters that the client has to store internally (e.g. channel id, token id, authentication token, sequence number, request id).
You need an OPC UA server implementation that supports WebSockets to test the client. Two options exist:
- Use open62541 with WebSockets enabled
- Use websockify for servers that do not support WebSockets (that only support TCP connections)
Learn how to use
check this example to see an simple OPCUA server that exposes 3 simple variables.
Creating a simple Client
check this example to see an simple OPCUA client that attempts to connect to a OPCUA server, print the end point and browse some variables. (Typescript)
Creating a virtual Weather Station OPC/UA Server
In this tutorial, we will use a REST API to access free weather data from cities around the world and expose them though a OPC/UA server.
Creating a HTML Dashboard to monitor a
check this example to see an simple OPCUA client that attempts to connect to a OPCUA server, print the end point and browse some variables.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
A lightweight OPC-UA client for node.js and the browser.
mrxdst/opc-ua
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
A lightweight OPC-UA client for node.js and the browser.
This library was built to fit my needs and doesn’t fully conform to any client profile.
Note: Only insecure endpoints are supported at the moment.
- TCP and WebSocket transports.
- Works in the browser (with webpack, WebSocket transport only).
- Auto-reconnect (with re-creation of subscriptions).
- null strings and null arrays are typed as undefined.
- Multidimensional arrays are implemented using ndarray.
This library relies on TypeScript for compile-time typechecks. Using wrong types is undefined behaviour.
import UaClient, AttributeIds, CreateMonitoredItemsRequest, CreateSubscriptionRequest, MonitoredItemCreateRequest, MonitoringMode, MonitoringParameters, ReadValueId, NodeId, NodeIds > from 'opc-ua'; main(); async function main(): Promisevoid> const client = new UaClient( endpointUrl: 'opc.tcp://localhost' >); await client.connect(); const subscription = await client.createSubscription(new CreateSubscriptionRequest( publishingEnabled: true, requestedPublishingInterval: 500, requestedLifetimeCount: 60, requestedMaxKeepAliveCount: 10 >)); const monitoredItems = await subscription.createMonitoredItems(new CreateMonitoredItemsRequest( itemsToCreate: [ new MonitoredItemCreateRequest( monitoringMode: MonitoringMode.Reporting, requestedParameters: new MonitoringParameters( samplingInterval: -1 >), itemToMonitor: new ReadValueId( nodeId: NodeId.parse(NodeIds.Server_ServerStatus_CurrentTime), attributeId: AttributeIds.Value >) >) ] >)); const monitoredItem = monitoredItems[0]; monitoredItem.on('value', dataValue => console.log(`Current time: $dataValue.value?.value?.toLocaleString()>`); >); >
About
A lightweight OPC-UA client for node.js and the browser.
Saved searches
Use saved searches to filter your results more quickly
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.
JavaScript OPC UA client has been implemented to subscribe to the server and monitor changes in the temperature sensor value. Upon detecting a change, the new value is saved to a PostgreSQL database
iliareshetov/node-opcua-client
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Sign In Required
Please sign in to use Codespaces.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching GitHub Desktop
If nothing happens, download GitHub Desktop and try again.
Launching Xcode
If nothing happens, download Xcode and try again.
Launching Visual Studio Code
Your codespace will open once ready.
There was a problem preparing your codespace, please try again.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
JavaScript OPC UA client that connects to a server using the OPC UA communication protocol.
The client subscribes to the server and continuously monitors a temperature sensor’s value.
Whenever the value changes, the new value is logged to the console and saved to a PostgreSQL database.
The code uses the «node-opcua» and «os» libraries to implement the OPC UA client and obtain the hostname of the device running the code.
About
JavaScript OPC UA client has been implemented to subscribe to the server and monitor changes in the temperature sensor value. Upon detecting a change, the new value is saved to a PostgreSQL database