JSON/JavsScript WebSite Feedback and Questions |OPC UA Implementation: Stacks, Tools, and Samples|Forum|OPC Foundation

Avatar
Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
Lost password?
sp_Feed sp_PrintTopic sp_TopicIcon
JSON/JavsScript WebSite Feedback and Questions
Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
1
03/30/2020 - 22:30
sp_Permalink sp_Print sp_EditHistory

The OPC Foundation has created a simple website to demonstrate how to use JSON, JavaScript and REST like APIs to communicate with the .NETStandard ReferenceServer (see https://github.com/OPCFoundati…..emo/webapi).

The site can be found here: https://prototyping.opcfoundation.org

This documentation for the JSON encoding is here: https://reference.opcfoundatio…..Part6/#5.4

The documentation for the the HTTPS binding is here: https://reference.opcfoundatio…..Part6/#7.4

The documentation for the WebSockets binding is here: https://reference.opcfoundatio…..Part6/#7.5

The documentation for the Sessionless Service calls used to implement the WebAPI is here: https://reference.opcfoundatio…..Part4/#6.3

This thread is for questions and discussions.

If someone has done their own OPC UA JSON/JavaScript implementation and they want to tell people about them please leave a link in this thread.

Avatar
Alexander Schäpper
New Member
Members
Forum Posts: 1
Member Since:
07/29/2019
sp_UserOfflineSmall Offline
2
04/08/2020 - 05:18
sp_Permalink sp_Print

Hello

I just tried the demosite prototyping.opcfoundation.org, and when using the Subscribe demo, its unable to connect to the OPC-UA Server at address prototyping.opcfoundation.org:62542. I remember the trainer from the demo said he had to open the port temporarly.

So am I right with the assumption that this sample will not work anymore at all or is it just a network / server issue and the server should be reachable again?

I want to build my own node.js / React / Typescript sample here in my office and need a server to get the data from.

Greetings and thanks for the nice example.

Alex

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
3
04/08/2020 - 07:37
sp_Permalink sp_Print

The server is still running, however, I cannot access from FireFox on some machines.

Edge seems to work.

You should also be able to use the .NET client to connect using websockets in:
https://github.com/OPCFoundati…../Reference

Avatar
Michael Derfler
New Member
Members
Forum Posts: 1
Member Since:
04/13/2020
sp_UserOfflineSmall Offline
4
04/13/2020 - 23:31
sp_Permalink sp_Print

Since the presentation the websocket example uses the non-reversible form (the example before used the reversible form).

Could you change it back to the reversible form?

NotificationData provides an array of ExtensionObjects and in the reversible form the type id of this ExtensionObject has to be present

This is not the case in the example:

 

{
    "TypeId": {
        "Id": 827
    },
    "Body": {
        "ResponseHeader": {
            "Timestamp": "2020-04-14T06:15:08.4207221Z",
            "RequestHandle": 6,
            "StringTable": []
        },
        "SubscriptionId": 15,
        "AvailableSequenceNumbers": [
            2
        ],
        "MoreNotifications": false,
        "NotificationMessage": {
            "SequenceNumber": 2,
            "PublishTime": "2020-04-14T06:15:08.4207221Z",
            "NotificationData": [
                {
                   "!!!!!!!!!!! TypeId IS MISSING !!!!!!!!!!!!!!!!!"
                    "Body": {
                        "MonitoredItems": [
                            {
                                "ClientHandle": 1,
                                "Value": {
                                    "Value": {
                                        "Type": 11,
                                        "Body": 1.789481742797868e+35
                                    },
                                    "SourceTimestamp": "2020-04-14T06:15:07.5858651Z"
                                }
                            }
                        ],
                        "DiagnosticInfos": []
                    }
                }
            ]
        },
        "Results": [
            0
        ],
        "DiagnosticInfos": []
    }
}
Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
5
04/13/2020 - 23:45
sp_Permalink sp_Print

That appears to be a bug in the encoder. I will have to investigate.

Avatar
rwbm
Member
Members
Forum Posts: 10
Member Since:
12/01/2019
sp_UserOfflineSmall Offline
6
05/12/2020 - 00:31
sp_Permalink sp_Print

To what degree is the WebSockets/JSON implementation actually subscription? The flow diagram shows that it’s basically just polling.

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
7
05/12/2020 - 01:57
sp_Permalink sp_Print

The UA subscription model includes flow control so updates are only sent after the client indicates it is ready to receive them.

Clients ready to received will send multiple Publish requests that are held on the server until changes to the data are detected.

When using a full-duplex channel like websockets the client can send the publish requests and then use the same channel for other services.

IOW, it make look like polling in a simple application but architecturally it is not.

Avatar
Frank Stegerwald
New Member
Members
Forum Posts: 1
Member Since:
05/15/2020
sp_UserOfflineSmall Offline
8
06/05/2020 - 03:52
sp_Permalink sp_Print

I have a architectural question to the solution:

does the browser communicates DIRECTLY to the opc ua server or 

is the communication always between browser <-> webserver <-> opc ua server

I dont get it, hope you can give me some insights

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
9
06/05/2020 - 10:15
sp_Permalink sp_Print

In theory, the JavaScript communicates directly with the UA server.

In practice, cross-sight scripting rules (CORS) mean scripts can only communicate with the site that served the scripts.

CORS could be addressed in a number of ways:

  1. Have the UA server act as a HTTP server that provides the HTML/scripts
  2. Use HTTP rewrite rules on the server that redirect JSON requests to the UA server (AKA reverse proxy);
  3. Have a web method forward the JSON to the UA server;

The example uses 3), however, this is least elegant solution.

2) is probably the best for real solution.

Avatar
Thomas Nordaunet
New Member
Members
Forum Posts: 1
Member Since:
07/03/2024
sp_UserOfflineSmall Offline
10
09/17/2024 - 03:51
sp_Permalink sp_Print

Hi. This seems to be a old post, but since it is a sticky I will try to post here instead of making a new post. 

1) The server/example seems to be down? Is it running on another URL?

2) Is the source code for the example available somewhere?

 

We are building a automation system using PLCs (Siemens and/or Codesys) but for the HMI we need to use standard html/js/web browser functionality. We are a bit stuck on the best architecture on this system. The PLS and HMI are on the same physical network, so they should be able to communicate with each other without to many security restrictions. We would like to reduce the complexity and number of hardware/servers to facilitate communication between the PLS and HMI, and thus would like to use standard REST API or websockets to communicate “directly” with the PLS without needing a web server/proxy/etc in the middle. Is this possible? 

Any one know if siemens and codesys supports JSON serialization and websocket communication? 

What are our options? We have made a working prototype using a “OPC-UA client to websocket server” using node.js in the middle but as mentioned previously it adds (unnecessary?) overhead and complexity.

Anyone knows if there is any opc-ua clients that works in the browser?

Avatar
Randy Armstrong
Admin
Forum Posts: 1579
Member Since:
05/30/2017
sp_UserOfflineSmall Offline
11
09/18/2024 - 19:49
sp_Permalink sp_Print sp_EditHistory

All the above is out of date.

As of 1.05.04, all JSON/WebSockets implementations are done with OpenAPI definitions.

Pure UA client written in TypeScript + React:
https://opcua-rest-dashboard.a…..sites.net/

Clicking ‘Connect’ will switch to WebSockets.

OpenAPI definition for API:
https://opcua-rest-dashboard.a…..et/swagger

Code is here (member only, preparing for public release):
https://github.com/OPCF-Member…..estGateway

Simple clients in Python and C#:
https://github.com/OPCF-Member…..RestClient

Code generated using OpenApi definitions.

Constants needs for a client will be normative files maintained by the OPC-F:

https://github.com/OPCF-Member…..st/OpenApi

 

https://github.com/OPCF-Member…..estGateway

Forum Timezone: America/Phoenix
Most Users Ever Online: 510
Currently Online:
Guest(s) 14
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 10
Topics: 1446
Posts: 4890