OpcUaWebServer icon indicating copy to clipboard operation
OpcUaWebServer copied to clipboard

READRESPONSE has a strange format

Open atimin opened this issue 5 years ago • 5 comments

Describe the bug

I've tried to read the value of a variable and got the following response:

{
    "Header": {
        "MessageType": "READ_RESPONSE",
        "ClientHandle": "1"
    },
    "Body": {
        "Value": {
            "Type": "1",
            "Body": "true"
        },
        "SourceTimestamp": "2019-07-26T11:10:20Z",
        "ServerTimestamp": "2019-07-26T11:10:20Z"
    }
}

First of all, the type is wrong anf equals 1. And I think, if variable 'Boolean' has type Boolean, the body should be true not string "ture".

To Reproduce

  1. Run demo application:
docker-compose run  -p 8080:8080 -p 8081:8081 -p 8082:8082 webserver
  1. Launch script:
  import websocket
  import json

   msg = {
      'Header': {
        'MessageType':'READ_REQUEST',
        'ClientHandle':'1'
      },
      'Body': { 'Variable' : 'Boolean'}
   }

 
  ws = websocket.create_connection('ws://127.0.0.1:8081')
  ws.send(json.dumps(msg)) 
  resp = ws.recv()  
  json.loads(resp)

Expected behavior

The expected message should be:

{
    "Header": {
        "MessageType": "READ_RESPONSE",
        "ClientHandle": "1"
    },
    "Body": {
        "Value": {
            "Type": "Boolean",
            "Body": "true"
        },
        "SourceTimestamp": "2019-07-26T11:10:20Z",
        "ServerTimestamp": "2019-07-26T11:10:20Z"
    }
}

atimin avatar Jul 26 '19 11:07 atimin

The type is an integer variable. These are not returned as a string.

The string "true" is actually an error. That's because json boost only allows strings. We can think about using another JSON parser.

huebl avatar Jul 27 '19 13:07 huebl

It works a bit confusing. ValueInfo Response returns the type as a string that stores the name of the type. Read Response returns the code of the type. What is why I habe taken it as a bug.

atimin avatar Jul 27 '19 14:07 atimin

We can think about using another JSON parser.

I can offer jsoncpp but we have to fix this before:

https://github.com/ASNeG/OpcUaStack/issues/252

atimin avatar Jul 27 '19 14:07 atimin

See Issue #41.

I think the own data types should be adapted to the OPC UA standard.

huebl avatar Jul 27 '19 14:07 huebl

I think the better solution of the JSON parser problem is to make some little workaround:

https://stackoverflow.com/questions/2855741/why-does-boost-property-tree-write-json-save-everything-as-string-is-it-possibl.

atimin avatar Jul 29 '19 04:07 atimin