Telnet from Node-RED running on Windows 10

In linux I'm able to run telnet in an exec node. I can't seem to make that happen in windows 10 and I'm not certain why.

I have tried to use node-red-contrib-telnet-client but I can't find any documentation or examples to help just get over the first hurdle which is sending login and password to a telnet server from node-red.

I have read the suggestion several times to use the TCP node to talk to a telnet server and I have been able to get the telnet server to negotiate options with the TCP request node by sending buffers of arrays with "will won't do don't" commands detailed here: Telnet Options

I still can't figure out how to send a TCP request that lets the Telnet server know that I would like to open a session with a username and password as I would in cmd or the terminal with the telnet command.

I feel like I'm missing something super basic here. In the end I'm attempting to have node-red access the telnet server on some Siemens PLCs to be able to pull out a few values.

Any help is greatly appreciated.

Are the S7 nodes not an option?

If it is really a simple telnet server it should be running like this:

  • establish a connection
  • the server will send to you: 'Username'
  • you should respond with a valid username followed by a \n
  • the server sends 'Password'
  • you should send a valid password followed by a \n
  • the server sends a welcome message or simply a system prompt.

At least this is how it works on my AMX or Crestron controllers.

On your windows system I would start by using Hyperterminal. You can install it quite easily and you can download it free. You can also use PuTTY. Just establish a connection on IP address and Port 23. If your Telnet device, in this case I'm assuming, it's the PLC, you should get a simple screen text menu which probably will accept commands. Telnet expects screen interactions, so it sends screen text values for menus and display. You can probably use it from nod-RED, but handle the screen information from the buffer.
Using Telnet, you need to connect to the Telnet server, sometimes this takes something to initiate that, like a carriage return once connected.

The devices are model PXC-36, the only available data access is via telnet. I do not think the s7 nodes are an option.

Does that PLC have bacnet ?

only via mstp not over IP

What I have done here to test is use an intel nuc running Ubuntu 20.04.2 to install telnetd
username is openhab password is habopen
I can confirm that I can get telnet access from the terminal

However I can't seem to get responses that I can parse when I attempt to use the TCP node.
When I listen on the tcp in node I get this buffer[12] before I ever try to send anything to the telnet server.
Then I get the same as a response if I use the request node.
I have worked out that it is the server making options negotiations

0: 255 IAC
1: 253 DO
2: 24 terminal type
3: 255 IAC
4: 253 DO
5: 32 terminal speed
6: 255 IAC
7: 253 DO
8: 35 X-DISPLAY-LOCATION (XDISPLOC)
9: 255 IAC
10: 253 DO
11: 39 NEW-ENVIRON

I haven't figured out how to get the telnet server to ask for my password the way the terminal will if I pass the option -l username along with telnet

Here's a stripped down flow of where I'm starting from. I also tried this using a raspi as the telnet server will the same results.

[{"id":"88d86f07.b3b768","type":"tab","label":"telnet","disabled":false,"info":""},{"id":"26096609.db0c12","type":"inject","z":"88d86f07.b3b768","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":140,"wires":[["5cf26d60.9c4dfc"]]},{"id":"5cf26d60.9c4dfc","type":"function","z":"88d86f07.b3b768","name":"uname","func":"msg.payload = Buffer.from(\"openhab\\r\\n\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":140,"wires":[["6ca876fc.a3624"]]},{"id":"531ef101.6d50a8","type":"inject","z":"88d86f07.b3b768","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":280,"y":180,"wires":[["e84bb2e8.a89898"]]},{"id":"e84bb2e8.a89898","type":"function","z":"88d86f07.b3b768","name":"pword","func":"msg.payload = Buffer.from(\"habopen\\r\\n\");\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":430,"y":180,"wires":[["6ca876fc.a3624"]]},{"id":"405767cc.8453f","type":"inject","z":"88d86f07.b3b768","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"telnet -l openhab","payloadType":"str","x":400,"y":80,"wires":[["6ca876fc.a3624"]]},{"id":"5290eb0f.d598fc","type":"tcp in","z":"88d86f07.b3b768","name":"","server":"client","host":"192.168.3.33","port":"23","datamode":"stream","datatype":"buffer","newline":"","topic":"","base64":false,"x":690,"y":160,"wires":[["623e4301.145cf4"]]},{"id":"623e4301.145cf4","type":"debug","z":"88d86f07.b3b768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":970,"y":160,"wires":[]},{"id":"6ca876fc.a3624","type":"tcp request","z":"88d86f07.b3b768","server":"192.168.3.33","port":"23","out":"sit","splitc":" ","name":"","x":700,"y":80,"wires":[["a1c736d5.0b8dc"]]},{"id":"a1c736d5.0b8dc","type":"debug","z":"88d86f07.b3b768","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":940,"y":80,"wires":[]}]

Ok I figured out what I didn't know that I needed to understand to make this work and I thought I'd share my findings with anyone else that might try to make a node-red telnet connection. I didn't use the telnet-client, I couldn't find any resources to understand how to use it. I didn't use TCP-IN or TCP-OUT nodes, I only used one TCP-Request node set to never close the connection. The biggest issue I had was when trying to replicate the commands I would type into a terminal to open the telnet connection I needed to use the carriage return and new line as a buffer and not a string. Instead of string = '\r\n' you need to send buffer = [80] for the telnet server to accept the return character.

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