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

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: 430
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: 430
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: 430
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: 8
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: 430
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: 430
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.

Forum Timezone: America/Phoenix
Most Users Ever Online: 202
Currently Online:
Guest(s) 19
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Forum Stats:
Groups: 2
Forums: 9
Topics: 718
Posts: 2101