Why isnt my payload being displayed in the browser?

Can anyone see what im missing here? When i load the page at 1270.0.01/t it starts the connection fine. I can see at my debug nodes that it is reading the values fine but when i load the browser i just see "The value of the payload is {}".

[
    {
        "id": "dfbe90bbe964e4a6",
        "type": "OpcUa-Item",
        "z": "b1cdb8634f302c96",
        "item": "ns=2;s=BAR-LIN-LINEH.PLC.CycleCount",
        "datatype": "Int32",
        "value": "",
        "name": "",
        "x": 500,
        "y": 320,
        "wires": [
            [
                "a57a83b1615a9e21"
            ]
        ]
    },
    {
        "id": "a57a83b1615a9e21",
        "type": "OpcUa-Client",
        "z": "b1cdb8634f302c96",
        "endpoint": "7290d8b0.f713d8",
        "action": "read",
        "deadbandvalue": "",
        "time": "5",
        "timeUnit": "s",
        "localfile": "",
        "localkeyfile": "",
        "folderName4PKI": "",
        "name": "Test server (subscribe items)",
        "x": 760,
        "y": 320,
        "wires": [
            [
                "5ccac9aebf6bc09d",
                "501da7f9abb42b8d"
            ]
        ]
    },
    {
        "id": "30507aab1156aa78",
        "type": "debug",
        "z": "b1cdb8634f302c96",
        "name": "debug 9",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1400,
        "y": 440,
        "wires": []
    },
    {
        "id": "649d958d3c688149",
        "type": "template",
        "z": "b1cdb8634f302c96",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "The value of the payload is {{payload}}",
        "output": "str",
        "x": 1240,
        "y": 520,
        "wires": [
            [
                "c3de8b5b0cbc7a70",
                "30507aab1156aa78"
            ]
        ]
    },
    {
        "id": "c3de8b5b0cbc7a70",
        "type": "http response",
        "z": "b1cdb8634f302c96",
        "name": "",
        "statusCode": "",
        "headers": {
            "content-type": "application/json"
        },
        "x": 1430,
        "y": 560,
        "wires": []
    },
    {
        "id": "5ccac9aebf6bc09d",
        "type": "json",
        "z": "b1cdb8634f302c96",
        "name": "",
        "property": "payload",
        "action": "",
        "pretty": false,
        "x": 1070,
        "y": 440,
        "wires": [
            [
                "649d958d3c688149"
            ]
        ]
    },
    {
        "id": "501da7f9abb42b8d",
        "type": "debug",
        "z": "b1cdb8634f302c96",
        "name": "debug 10",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "statusVal": "",
        "statusType": "auto",
        "x": 1380,
        "y": 320,
        "wires": []
    },
    {
        "id": "573a1a7218909536",
        "type": "http in",
        "z": "b1cdb8634f302c96",
        "name": "",
        "url": "t",
        "method": "get",
        "upload": false,
        "swaggerDoc": "",
        "x": 370,
        "y": 640,
        "wires": [
            [
                "dfbe90bbe964e4a6",
                "5ccac9aebf6bc09d"
            ]
        ]
    },
    {
        "id": "7290d8b0.f713d8",
        "type": "OpcUa-Endpoint",
        "endpoint": "opc.tcp://10.50.66.175:49320",
        "none": false,
        "login": false,
        "usercert": false,
        "usercertificate": "",
        "userprivatekey": ""
    }
]

Remove this wire.
you are responding to the request before it travels through your opcua nodes

(I think :sweat_smile: )

As long as the HTTP Response node is at the end of the line
(and importantly, you don't re-declare msg anywhere) it will respond with the payload that has been picked up on the way)

Thanks for your reply.
When i remove this wire, my page never loads. just sits there loading. Not really sure why.

looking in the node-red cmd window i get the message

22 Mar 11:44:31 - [error] [http response:c3de8b5b0cbc7a70] RangeError [ERR_HTTP_INVALID_STATUS_CODE]: Invalid status code: Good (0x00000000)

Try

All I have done is set the status code

[{"id":"dfbe90bbe964e4a6","type":"OpcUa-Item","z":"0f37a6818e63a54f","item":"ns=2;s=BAR-LIN-LINEH.PLC.CycleCount","datatype":"Int32","value":"","name":"","x":280,"y":210,"wires":[["a57a83b1615a9e21"]]},{"id":"a57a83b1615a9e21","type":"OpcUa-Client","z":"0f37a6818e63a54f","endpoint":"7290d8b0.f713d8","action":"read","deadbandvalue":"","time":"5","timeUnit":"s","localfile":"","localkeyfile":"","folderName4PKI":"","name":"Test server (subscribe items)","x":290,"y":290,"wires":[["5ccac9aebf6bc09d","501da7f9abb42b8d"]]},{"id":"c3de8b5b0cbc7a70","type":"http response","z":"0f37a6818e63a54f","name":"","statusCode":"200","headers":{"content-type":"application/json"},"x":660,"y":350,"wires":[]},{"id":"5ccac9aebf6bc09d","type":"json","z":"0f37a6818e63a54f","name":"","property":"payload","action":"","pretty":false,"x":465,"y":350,"wires":[["c3de8b5b0cbc7a70"]]},{"id":"501da7f9abb42b8d","type":"debug","z":"0f37a6818e63a54f","name":"debug 10","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":660,"y":290,"wires":[]},{"id":"573a1a7218909536","type":"http in","z":"0f37a6818e63a54f","name":"","url":"t","method":"get","upload":false,"swaggerDoc":"","x":80,"y":210,"wires":[["dfbe90bbe964e4a6"]]}]

That works great thankyou. I think i better read about statuscodes. Not sure why that makes it work. Thankyou for your assistance sir!

1 Like

Below is the list of HTTP Response codes - we used 200

Code Constant Reason Phrase
100 CONTINUE Continue
101 SWITCHING_PROTOCOLS Switching Protocols
102 PROCESSING Processing
200 OK OK
201 CREATED Created
202 ACCEPTED Accepted
203 NON_AUTHORITATIVE_INFORMATION Non Authoritative Information
204 NO_CONTENT No Content
205 RESET_CONTENT Reset Content
206 PARTIAL_CONTENT Partial Content
207 MULTI_STATUS Multi-Status
300 MULTIPLE_CHOICES Multiple Choices
301 MOVED_PERMANENTLY Moved Permanently
302 MOVED_TEMPORARILY Moved Temporarily
303 SEE_OTHER See Other
304 NOT_MODIFIED Not Modified
305 USE_PROXY Use Proxy
307 TEMPORARY_REDIRECT Temporary Redirect
308 PERMANENT_REDIRECT Permanent Redirect
400 BAD_REQUEST Bad Request
401 UNAUTHORIZED Unauthorized
402 PAYMENT_REQUIRED Payment Required
403 FORBIDDEN Forbidden
404 NOT_FOUND Not Found
405 METHOD_NOT_ALLOWED Method Not Allowed
406 NOT_ACCEPTABLE Not Acceptable
407 PROXY_AUTHENTICATION_REQUIRED Proxy Authentication Required
408 REQUEST_TIMEOUT Request Timeout
409 CONFLICT Conflict
410 GONE Gone
411 LENGTH_REQUIRED Length Required
412 PRECONDITION_FAILED Precondition Failed
413 REQUEST_TOO_LONG Request Entity Too Large
414 REQUEST_URI_TOO_LONG Request-URI Too Long
415 UNSUPPORTED_MEDIA_TYPE Unsupported Media Type
416 REQUESTED_RANGE_NOT_SATISFIABLE Requested Range Not Satisfiable
417 EXPECTATION_FAILED Expectation Failed
418 IM_A_TEAPOT I'm a teapot
419 INSUFFICIENT_SPACE_ON_RESOURCE Insufficient Space on Resource
420 METHOD_FAILURE Method Failure
421 MISDIRECTED_REQUEST Misdirected Request
422 UNPROCESSABLE_ENTITY Unprocessable Entity
423 LOCKED Locked
424 FAILED_DEPENDENCY Failed Dependency
428 PRECONDITION_REQUIRED Precondition Required
429 TOO_MANY_REQUESTS Too Many Requests
431 REQUEST_HEADER_FIELDS_TOO_LARGE Request Header Fields Too Large
451 UNAVAILABLE_FOR_LEGAL_REASONS Unavailable For Legal Reasons
500 INTERNAL_SERVER_ERROR Internal Server Error
501 NOT_IMPLEMENTED Not Implemented
502 BAD_GATEWAY Bad Gateway
503 SERVICE_UNAVAILABLE Service Unavailable
504 GATEWAY_TIMEOUT Gateway Timeout
505 HTTP_VERSION_NOT_SUPPORTED HTTP Version Not Supported
507 INSUFFICIENT_STORAGE Insufficient Storage
511 NETWORK_AUTHENTICATION_REQUIRED Network Authentication Required

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.