Mcprotocol logging bad quality then uncaught exception


error text:
"
Response Header is not valid
Logging a Bad Quality the Pointer 0
"
it usually runs correctly but sometimes it disconnceted when i read data from mcprotocol PLC.Is there something wrong with the PLC?
It will be good when i restart the node-red,but i can't monitor its state all the time, >-<
How can i fix it? :blush:

This does not actually appear to be related to Dashboard but does appear to be related to some specific hardware? If so, could you please update the tag and add some detail about the hardware in use.

Can you tell us what version of node-red-contrib-mcprotocol you have installed?

Can you copy and paste (as text, not image) the info AFTER "Uncaught Exception" (that is the important part)

the version of node-red-contrib-mcprotocol is V1.2.1
//
It's not the same error code,but the same error text whitch is "Logging a Bad quality..".I can't log in that wrong server right now.I will paste it tomorrow.

2024-03-01T00:10:27.549Z 11141 ] Logging a Bad Quality thePointer 42
[2024-03-01T00:10:27.549Z 11311 ] Logging a Bad Quality thePointer 44
[2024-03-01T00:10:27.549Z 11488 ] Logging a Bad Quality thePointer 46
[2024-03-01T00:10:29.052Z 514126  192.168.120.53] We Caught a read/write error ECONNRESET - resetting connection
1 Mar 08:10:29 - [mcprotocol] error ~ mcprotocol: {host:'192.168.120.53', port: 4999}: Error: read ECONNRESET
Error: read ECONNRESET
    at TCP.onStreamRead (internal/stream_base_commons.js:209:20) {
  errno: -4077,
  code: 'ECONNRESET',
  syscall: 'read'
}

OK,Thanks for reminding.

You might need to share the config setup. For example, over 10 years maintaining Mitsi PLCs, I learned how notoriously flaky Mitsi Ethernet comms were. Especially TCP - to the point where I had to schedule in production downtime to get the PLC powered off/on to recover the connection (A, QnA, Q series Ethernet cards).

If your PLC supports it, I strongly recommend UDP mode and 4E frames. 4E frames have a sid (sequence ID) embedded in their frames which makes this the mode reliable method of communication.

As for recovery, the MC Read or MC Write node can be sent a specially crafted msg to disconnect/connect. You can add logic to your flows to either monitor the status of an MC Read or catch the errors, perform some logic/delay testing, issue a disconnect, then a connect msg.

EDIT:

The special messages supported are:

msg.disconnect true
msg.connect true
msg.reinitialize true

msg.topic "disconnect"
msg.topic "connect"
msg.topic "reinitialize"

Sending any one of these will perform the action it describes.

Thank you very much for your detailed reply,i'll try it later :heart:

Unfortunately,this PLC does't support UDP mode and 4E frames both :face_exhaling:.I'll add 'catch' and 'function' module to monitor PLC's status to reconnect if it disconnects.Thanks for help!

Dear expert,it went wrong again :sob:


fortunately,it's a error not disconnection :thinking:
It will be good if i redeploy the flow.This is too troublesome and will affect my statistical device OEE :pensive:


Whether the contents of my function are correct?

No. Only one action at a time is possible. So I would probably recommend only msg.reinitialize=true.

1 Like

Thank you Steve,this flow has run correctly for a week,but it still has a error.


error code shows "message exceed maximum catch quantity".What does it mean?

I don't recognise that message.

Is that something you have generated? Share the post of your flow that does this read & the catch node and what the catch connects to

I'll share it if it shows again.


"邮件超过最大捕获数量" means messages exceed the maximum number of captures.
I just need to click deploy and it will be good :joy:

I need you to share the flow not a screenshot.

Select those nodes, press ctrl+e, copy to clipboard, paste into a reply.

[{"id":"a058c883.9490a8","type":"catch","z":"ce52da99.7def78","name":"","scope":["8a2d13f0.aaff4"],"uncaught":false,"x":110,"y":160,"wires":[["437a1dbc.d68314"]]},{"id":"437a1dbc.d68314","type":"function","z":"ce52da99.7def78","name":"","func":"\nmsg.reinitialize=true;\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":350,"y":160,"wires":[["8a2d13f0.aaff4"]]},{"id":"a56e288f.539ef8","type":"inject","z":"ce52da99.7def78","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"1","crontab":"","once":true,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":350,"y":40,"wires":[["8a2d13f0.aaff4"]]},{"id":"35834e6a.d5e822","type":"function","z":"ce52da99.7def78","name":"","func":"\nmsg.payload.device_id='XQQD-Z-202'\nvar temp=msg.payload;\nvar res={}\nvar payload={};\n\n\n//判断数量是否变化\nvar cur_product_num = temp.D7857;\nvar cur_device_id=temp.device_id\nvar pre_product_num=0\n\n//获取上一个产品的数量\npre_product_num = flow.get(\"device1_pre_product_num\");\n\nif (pre_product_num==0){\n    flow.set(\"device1_pre_product_num\", cur_product_num);\n}\nelse if (pre_product_num != cur_product_num){\n    //数量变化后再进行字段映射\n    //暂存当前产品数量为上一个产品数量\n    flow.set(\"device1_pre_product_num\", cur_product_num);\n    payload.preheating_temperature = temp.D7850\n    payload.preheating_time = temp.D7851\n    payload.mold_temperature = temp.D7852\n    payload.maximum_angle = temp.D7853\n    payload.powder_weight = temp.D7854\n    payload.afterheating_temperature = temp.D7855\n    payload.afterheating_time = temp.D7856\n    payload.processing_quantity = temp.D7857\n    payload.device_id=temp.device_id\n\n    \n    //转换产品名称,将整型格式的产品名称转换成字符串\n    var productname=\"\"\n    var index=0\n    for (;index<=15;index++){\n        let lastindex=7858+index\n        let addstrindex= 'D'+lastindex\n        var intd7858=temp[addstrindex]\n        \n        if(intd7858==0){\n            break\n        }\n        var bitd7858=intd7858.toString(2)\n        length=bitd7858.length\n        zerostr=\"\"\n        for(;length<16;length++){\n            zerostr=zerostr+\"0\"\n        }\n        bitd7858=zerostr+bitd7858\n        var x1=bitd7858.substring(0,8)\n        \n        var low8bitd7858=bitd7858.substring(0,8)\n        var high8bitd7858=bitd7858.substring(8,16)\n        var lowchar=String.fromCharCode(parseInt(low8bitd7858, 2));\n        var highchar=String.fromCharCode(parseInt(high8bitd7858, 2));\n        \n        productname=productname+highchar+lowchar\n    }\n    \n    payload.mold_code=productname.trim()\n    \n    msg.payload=payload\n    //将当前结果暂存为上一个\n    flow.set(\"device1_pre_res\", payload);\n    \n    return msg;\n}","outputs":1,"noerr":0,"initialize":"","finalize":"","x":730,"y":160,"wires":[["bfd10f6a.1d5d3","13ef4ae0.7a07a5"]]},{"id":"bfd10f6a.1d5d3","type":"http request","z":"ce52da99.7def78","name":"","method":"POST","ret":"txt","paytoqs":"ignore","url":"https://jsxq.group/slushMoldings/saveNoLogin","tls":"","persist":false,"proxy":"","authType":"","x":980,"y":160,"wires":[[]]},{"id":"13ef4ae0.7a07a5","type":"debug","z":"ce52da99.7def78","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":970,"y":60,"wires":[]},{"id":"8a2d13f0.aaff4","type":"MC Read","z":"ce52da99.7def78","name":"","topic":"","connection":"49014d6b.ab6ef4","address":"D7850,24","addressType":"str","outputFormat":0,"errorHandling":"throw","outputs":1,"x":540,"y":160,"wires":[["35834e6a.d5e822"]]},{"id":"49014d6b.ab6ef4","type":"MC Protocol Connection","name":"","host":"192.168.205.66","port":"5001","protocol":"TCP","frame":"3E","plcType":"QnA","ascii":false,"PLCStation":"","PCStation":"","PLCModuleNo":"","network":"","octalInputOutput":false,"timeout":"1000"}]

admin edit: wrap flow in triple backticks to make it importable

Your catch is causing a loop. Here is how i would limit it:

use ctrl+i to import

[{"id":"3ad37c94568d82ca","type":"catch","z":"3642c7ee286f9c17","name":"","scope":["97a58f9d8b285a7d"],"uncaught":false,"x":130,"y":740,"wires":[["4d61fbafe16cded9"]]},{"id":"4fd40519fefb0f21","type":"function","z":"3642c7ee286f9c17","name":"disconnect","func":"\nreturn {topic:\"disconnect\"}","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":510,"y":740,"wires":[["1ef4ba9a9009a223","ac45f05633e9325d"]]},{"id":"039feddc08cebc07","type":"inject","z":"3642c7ee286f9c17","name":"Poll for data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":510,"y":660,"wires":[["ac45f05633e9325d"]]},{"id":"5b8b66e1ef8db0eb","type":"function","z":"3642c7ee286f9c17","name":"","func":"\nmsg.payload.device_id='XQQD-Z-202'\nvar temp=msg.payload;\nvar res={}\nvar payload={};\n\n\n//判断数量是否变化\nvar cur_product_num = temp.D7857;\nvar cur_device_id=temp.device_id\nvar pre_product_num=0\n\n//获取上一个产品的数量\npre_product_num = flow.get(\"device1_pre_product_num\");\n\nif (pre_product_num==0){\n    flow.set(\"device1_pre_product_num\", cur_product_num);\n}\nelse if (pre_product_num != cur_product_num){\n    //数量变化后再进行字段映射\n    //暂存当前产品数量为上一个产品数量\n    flow.set(\"device1_pre_product_num\", cur_product_num);\n    payload.preheating_temperature = temp.D7850\n    payload.preheating_time = temp.D7851\n    payload.mold_temperature = temp.D7852\n    payload.maximum_angle = temp.D7853\n    payload.powder_weight = temp.D7854\n    payload.afterheating_temperature = temp.D7855\n    payload.afterheating_time = temp.D7856\n    payload.processing_quantity = temp.D7857\n    payload.device_id=temp.device_id\n\n    \n    //转换产品名称,将整型格式的产品名称转换成字符串\n    var productname=\"\"\n    var index=0\n    for (;index<=15;index++){\n        let lastindex=7858+index\n        let addstrindex= 'D'+lastindex\n        var intd7858=temp[addstrindex]\n        \n        if(intd7858==0){\n            break\n        }\n        var bitd7858=intd7858.toString(2)\n        length=bitd7858.length\n        zerostr=\"\"\n        for(;length<16;length++){\n            zerostr=zerostr+\"0\"\n        }\n        bitd7858=zerostr+bitd7858\n        var x1=bitd7858.substring(0,8)\n        \n        var low8bitd7858=bitd7858.substring(0,8)\n        var high8bitd7858=bitd7858.substring(8,16)\n        var lowchar=String.fromCharCode(parseInt(low8bitd7858, 2));\n        var highchar=String.fromCharCode(parseInt(high8bitd7858, 2));\n        \n        productname=productname+highchar+lowchar\n    }\n    \n    payload.mold_code=productname.trim()\n    \n    msg.payload=payload\n    //将当前结果暂存为上一个\n    flow.set(\"device1_pre_res\", payload);\n    \n    return msg;\n}","outputs":1,"timeout":"","noerr":7,"initialize":"","finalize":"","libs":[],"x":960,"y":740,"wires":[["4512f4e1d8e71580"]]},{"id":"4512f4e1d8e71580","type":"debug","z":"3642c7ee286f9c17","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1150,"y":740,"wires":[]},{"id":"97a58f9d8b285a7d","type":"MC Read","z":"3642c7ee286f9c17","name":"","topic":"","connection":"49014d6b.ab6ef4","address":"D7850,24","addressType":"str","outputFormat":"0","errorHandling":"throw","outputs":1,"x":800,"y":740,"wires":[["5b8b66e1ef8db0eb"]]},{"id":"b5455ab990f64c4e","type":"inject","z":"3642c7ee286f9c17","name":"reconnect","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":300,"y":660,"wires":[["4fd40519fefb0f21"]]},{"id":"4d61fbafe16cded9","type":"delay","z":"3642c7ee286f9c17","name":"","pauseType":"rate","timeout":"5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"10","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":true,"allowrate":false,"outputs":1,"x":320,"y":740,"wires":[["4fd40519fefb0f21"]]},{"id":"1ef4ba9a9009a223","type":"delay","z":"3642c7ee286f9c17","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"allowrate":false,"outputs":1,"x":500,"y":780,"wires":[["88a761827e38c846"]]},{"id":"88a761827e38c846","type":"function","z":"3642c7ee286f9c17","name":"connect","func":"\nreturn {topic:\"connect\"}","outputs":1,"timeout":"","noerr":0,"initialize":"","finalize":"","libs":[],"x":500,"y":820,"wires":[["ac45f05633e9325d"]]},{"id":"6e5d66284e027773","type":"debug","z":"3642c7ee286f9c17","name":"debug 8","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":800,"y":820,"wires":[]},{"id":"ac45f05633e9325d","type":"junction","z":"3642c7ee286f9c17","x":680,"y":740,"wires":[["97a58f9d8b285a7d","6e5d66284e027773"]]},{"id":"49014d6b.ab6ef4","type":"MC Protocol Connection","name":"","host":"192.168.205.66","port":"5001","protocol":"TCP","frame":"3E","plcType":"QnA","ascii":false,"PLCStation":"","PCStation":"","PLCModuleNo":"","network":"","octalInputOutput":false,"timeout":"1000"}]

As for your function, there are better ways to parse the data. You can use node-red-contrib-buffer-parser to make sense of the PLC data without a huge function! - e.g:

chrome_bzHfyzrdcg

[{"id":"e545ea8ee860f737","type":"buffer-parser","z":"3642c7ee286f9c17","name":"","data":"payload","dataType":"msg","specification":"spec","specificationType":"ui","items":[{"type":"int16le","name":"preheating_temperature","offset":0,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"preheating_time","offset":2,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"int16le","name":"mold_temperature","offset":4,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"maximum_angle","offset":6,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"powder_weight","offset":8,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"afterheating_temperature","offset":10,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"int16le","name":"afterheating_time","offset":12,"length":1,"offsetbit":0,"scale":"/10","mask":""},{"type":"int16le","name":"processing_quantity","offset":14,"length":1,"offsetbit":0,"scale":"1","mask":""},{"type":"ascii","name":"mold_code","offset":16,"length":30,"offsetbit":0,"scale":"1","mask":""}],"swap1":"swap16","swap2":"","swap3":"","swap1Type":"swap","swap2Type":"swap","swap3Type":"swap","msgProperty":"payload","msgPropertyType":"str","resultType":"keyvalue","resultTypeType":"return","multipleResult":false,"fanOutMultipleResult":false,"setTopic":true,"outputs":1,"x":2070,"y":120,"wires":[["140735407da290da"]]},{"id":"b44de05dc63f404a","type":"MC Read","z":"3642c7ee286f9c17","name":"Read D7850,24","topic":"","connection":"f9c2667da94e59e8","address":"D7850,24","addressType":"str","outputFormat":"1","errorHandling":"throw","outputs":1,"x":1880,"y":120,"wires":[["e545ea8ee860f737"]]},{"id":"140735407da290da","type":"debug","z":"3642c7ee286f9c17","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":2080,"y":180,"wires":[]},{"id":"5a3f2b8e912c4bc5","type":"inject","z":"3642c7ee286f9c17","name":"Poll for data","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":1690,"y":120,"wires":[["b44de05dc63f404a"]]},{"id":"f9c2667da94e59e8","type":"MC Protocol Connection","name":"","host":"localhost","port":"5003","protocol":"UDP","frame":"4E","plcType":"Q","ascii":false,"PLCStation":"","PCStation":"","PLCModuleNo":"","network":"","octalInputOutput":false,"timeout":"3000"}]
1 Like

node-red-contrib-buffer-parserIt's very useful and I'll look into it.Steve, thank you so much for your patient guidance. :+1:

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