Get values from server MS4D (Modbus TCP)

Hello, I'm new in NR. I have a quastion: a have a virtual machine with NR on one PC and server on other PC. I try to get values, using modbus TCP from the server MasterScada4D. All machines use one lan and have ping. Server with MS4D work on 192.168.10.18, machine with NR work on 192.168.10.33.

I install node-red-contrib-modbus v5.14.1 and try to conect with server, using "Modbus Server" with this parameters:
Hostname 192.168.10.18
Port 10502
Coils 0
Holdings 2
Inputs 0
Discretes 0

On server with MS4D I use the same port 10502 for modbus TCP and one test parameter in external channal.

But when I deploy, i have no connection with server, and in the PowerShell have this error:
Error: listen EADDRNOTAVAIL: address not available 192.168.10.18:10502
at Server.setupListenHandle [as _listen2] (net.js:1283:19)
at listenInCluster (net.js:1348:12)
at doListen (net.js:1487:7)
at processTicksAndRejections (internal/process/task_queues.js:81:21)

Can someone help me with this problem?

what if you use as Hostname 0.0.0.0

read this thread

also you can check the modbus Server examples from
Import > Examples > node-red-contrib-modbus > Modbus-Buffer-Server

I'll try to use hostname 0.0.0.0, and I've another error:
Error: getaddrinfo ENOTFOUND 0:0:0:0
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:60:26)

When I use examples with default parameters or use port 10502, I have the same error

Use Modbus Read instead of Modbus Server

I think Maksim is trying to setup his node-red with the modbus server node to push modbus data to his MasterScada4D software.

@MaksimKr i tried the 0.0.0.0 on my system and it seems to be working.
Can you try this flow that has a basic server and also has a Modbus read node in the same flow to see at least from the flow itself if you can read some values ?

[{"id":"18336ed.bd8a491","type":"debug","z":"937cb040.d8e16","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":415,"y":80,"wires":[],"l":false},{"id":"6c3e6f27.502e18","type":"comment","z":"937cb040.d8e16","name":"Information","info":"The Modbus Server and Modbus Flex Server \nworking with all reading and writing nodes.\n\nThese are two different servers \nfrom different libraries.\n\nThe simple examples hold \nthe same functions for both servers.\n","x":570,"y":140,"wires":[]},{"id":"d6a5dd3e.6e2f8","type":"function","z":"937cb040.d8e16","name":"","func":"msg.payload = {\n    'value': [1,1,1], \n    'register': 'input', \n    'address': 0 , \n    'disableMsgOutput' : 0 \n}; \nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":215,"y":280,"wires":[["1caf5383.ecd054"]],"l":false},{"id":"e75975bb.e98128","type":"inject","z":"937cb040.d8e16","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":155,"y":280,"wires":[["d6a5dd3e.6e2f8"]],"l":false},{"id":"b4397fad.8ffaa","type":"function","z":"937cb040.d8e16","name":"","func":"msg.payload = {\n    'value': [233,234,235], \n    'register': 'holding', \n    'address': 0 , \n    'disableMsgOutput' : 0 \n}; \nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":215,"y":320,"wires":[["1caf5383.ecd054"]],"l":false},{"id":"2676e2cd.f34d36","type":"inject","z":"937cb040.d8e16","name":"","props":[{"p":"payload","v":"true","vt":"bool"},{"p":"topic","v":"","vt":"string"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":75,"y":320,"wires":[["b4397fad.8ffaa"]],"l":false},{"id":"cbee0647.5cb71","type":"function","z":"937cb040.d8e16","name":"","func":"msg.payload = {\n    'value': [1, 1, 1, 1, 1, 1, 1, 0],\n    'register': 'coils', \n    'address': 0 , \n    'disableMsgOutput' : 1 \n}; \nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":215,"y":360,"wires":[["1caf5383.ecd054"]],"l":false},{"id":"1f92d036.c8f418","type":"inject","z":"937cb040.d8e16","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":155,"y":360,"wires":[["cbee0647.5cb71"]],"l":false},{"id":"6561bf00.a24e9","type":"function","z":"937cb040.d8e16","name":"","func":"msg.payload = {\n    'value': [true,true,true], \n    'register': 'discrete', \n    'address': 0 , \n    'disableMsgOutput' : 0 \n}; \nreturn msg;\n\n","outputs":1,"noerr":0,"x":215,"y":400,"wires":[["1caf5383.ecd054"]],"l":false},{"id":"6309b3fc.cd9294","type":"inject","z":"937cb040.d8e16","d":true,"name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":155,"y":400,"wires":[["6561bf00.a24e9"]],"l":false},{"id":"1caf5383.ecd054","type":"link out","z":"937cb040.d8e16","name":"","links":["7328d10f.1b78"],"x":295,"y":340,"wires":[]},{"id":"7328d10f.1b78","type":"link in","z":"937cb040.d8e16","name":"","links":["1caf5383.ecd054"],"x":75,"y":80,"wires":[["ef501f41b4d30c54"]]},{"id":"f9e611ca.64c348","type":"catch","z":"937cb040.d8e16","name":"","scope":null,"uncaught":false,"x":535,"y":280,"wires":[["f8090829.87c3c"]],"l":false},{"id":"f8090829.87c3c","type":"debug","z":"937cb040.d8e16","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":615,"y":280,"wires":[],"l":false},{"id":"257b008693b81069","type":"modbus-read","z":"937cb040.d8e16","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"8","rate":"5","rateUnit":"s","delayOnStart":false,"startDelayTime":"","server":"d9a243e58f12f2f1","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":530,"y":420,"wires":[[],["8d4f8f1d68c6fb1e"]]},{"id":"8d4f8f1d68c6fb1e","type":"debug","z":"937cb040.d8e16","name":"buffer","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload.buffer","targetType":"msg","statusVal":"","statusType":"auto","x":680,"y":420,"wires":[]},{"id":"ef501f41b4d30c54","type":"modbus-server","z":"937cb040.d8e16","name":"","logEnabled":true,"hostname":"0.0.0.0","serverPort":"10512","responseDelay":100,"delayUnit":"ms","coilsBufferSize":"8","holdingBufferSize":"8","inputBufferSize":"8","discreteBufferSize":"8","showErrors":true,"x":240,"y":80,"wires":[["18336ed.bd8a491"],["18336ed.bd8a491"],["18336ed.bd8a491"],["18336ed.bd8a491"],["18336ed.bd8a491"]]},{"id":"d9a243e58f12f2f1","type":"modbus-client","name":"","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"127.0.0.1","tcpPort":"10512","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

Inject some Holding register values and check if you see them.

Other things you can check whether any firewall is blocking that port.

Thank you, Frank, I use "modbus flex getter" and i can get data from server. Firstly i think, that i will initialaze the server and then read data, but "modbus server" was unnecessary. Problem was in value of quantity. I change value and get data from server MS4D. Problem was solved.

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