String type difference

Hello,

I am trying to combine the data from several Serial > TCP servers (lantronix Xport) in to a single TCP server (node-red).

For some reason when I make an inject node to send a string it differs from the string I get from the TCP node:image
The reply to TCP only works with the 'inject' node.

This is my flow:

Is there a difference between the string types?

here is the full flow

`[{"id":"8216e876.5c05c8","type":"tab","label":"Test VCOM serial server","disabled":false,"info":""},{"id":"202d55a3.441bba","type":"tcp in","z":"8216e876.5c05c8","name":"Server holding connections at :1025","server":"server","host":"192.168.5.1","port":"1025","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"text","base64":false,"x":160,"y":400,"wires":[["328f6b27.749164","c8e1dfef.00d88"]]},{"id":"a31a50d0.5a20c","type":"tcp out","z":"8216e876.5c05c8","host":"","port":"","beserver":"reply","base64":false,"end":false,"name":"reply: all open connections will be messaged","x":970,"y":360,"wires":[]},{"id":"be5cc07b.18ac8","type":"debug","z":"8216e876.5c05c8","name":"show incomming text at the debug tab","active":false,"console":"false","complete":"payload","x":890,"y":480,"wires":[]},{"id":"accb9163.6d532","type":"inject","z":"8216e876.5c05c8","name":"button: create a msg","topic":"","payload":"Hello from THE server.","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":190,"y":340,"wires":[["9aaf358.43926c8"]]},{"id":"328f6b27.749164","type":"template","z":"8216e876.5c05c8","name":"\"SERVER GOT:\" +","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SERVER GOT:\n{{payload}}","x":590,"y":480,"wires":[["be5cc07b.18ac8"]]},{"id":"c8e1dfef.00d88","type":"template","z":"8216e876.5c05c8","name":"modify received msg to be send back","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"You were sending: {{payload}}\n","x":550,"y":400,"wires":[["a31a50d0.5a20c"]]},{"id":"9aaf358.43926c8","type":"template","z":"8216e876.5c05c8","name":"+ newline","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}\n","output":"str","x":600,"y":340,"wires":[["a31a50d0.5a20c"]]},{"id":"ed17bfff.14b74","type":"debug","z":"8216e876.5c05c8","name":"show incomming text at the debug tab","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":710,"y":860,"wires":[]},{"id":"dffec33c.659c2","type":"inject","z":"8216e876.5c05c8","name":"button: create a msg","topic":"","payload":"Hello from THE client.","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":250,"y":680,"wires":[["894499a9.3b8948"]]},{"id":"b9aa7716.cc7aa8","type":"tcp out","z":"8216e876.5c05c8","host":"","port":"","beserver":"reply","base64":false,"end":false,"name":"reply: the server will get messaged","x":820,"y":680,"wires":[]},{"id":"acd6dd95.57de9","type":"tcp in","z":"8216e876.5c05c8","name":"Node-RED Client","server":"client","host":"localhost","port":"1025","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"text2","base64":false,"x":200,"y":800,"wires":[["d0a7631.e0a1ca","fb56724d.274ed"]]},{"id":"d0a7631.e0a1ca","type":"template","z":"8216e876.5c05c8","name":"\"CLIENT GOT:\" +","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"CLIENT GOT:\n{{payload}}","x":450,"y":860,"wires":[["ed17bfff.14b74"]]},{"id":"e8324c24.d0d98","type":"comment","z":"8216e876.5c05c8","name":"Telnet client: open your command prompt, and type: `telnet localhost 1025` and start typing","info":"Telnet client: open your command prompt, and type: `telnet localhost 1025` and start typing","x":470,"y":1640,"wires":[]},{"id":"894499a9.3b8948","type":"template","z":"8216e876.5c05c8","name":"+ newline","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}\n","output":"str","x":480,"y":680,"wires":[["b9aa7716.cc7aa8","b6237e99.e8fcf"]]},{"id":"fb56724d.274ed","type":"template","z":"8216e876.5c05c8","name":"no msg back, we do behave!","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","x":500,"y":760,"wires":[["b9aa7716.cc7aa8"]]},{"id":"c8f799d7.262f48","type":"tcp in","z":"8216e876.5c05c8","name":"Connect to Lantronix","server":"client","host":"10.2.9.138","port":"10001","datamode":"stream","datatype":"utf8","newline":"/n","topic":"","base64":false,"x":190,"y":200,"wires":[["9de08f5a.773e9","9aaf358.43926c8"]]},{"id":"9de08f5a.773e9","type":"debug","z":"8216e876.5c05c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":490,"y":200,"wires":[]},{"id":"b6237e99.e8fcf","ty`Preformatted text`pe":"debug","z":"8216e876.5c05c8","name":"show incomming text at the debug tab","active":false,"console":"false","complete":"payload","x":830,"y":600,"wires":[]},{"id":"d4873d8a.b768a","type":"inject","z":"8216e876.5c05c8","name":"S01,01,01,80 ","topic":"","payload":"S01,01,01,80","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":210,"y":300,"wires":[["9aaf358.43926c8","45c64991.3fe898"]]},{"id":"45c64991.3fe898","type":"debug","z":"8216e876.5c05c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":730,"y":220,"wires":[]}]`

Welcome to the forum @PiMo131.

You have truncated the end of the debug output from the first one, and it seems to be highlighted somehow, can you paste it again please.

Edit Also, when pasting a flow you have to use the </> button at the top of the forum entry window when pasting it.

Thanks Colin!

is this a better cut:

image

or this:

You said the strings were different and posted an image showing them looking different. It isn't the strings that are different but the rest of the message. If you change the debug node to show Complete Message I suspect you will find there is other stuff in the message that your reply node needs.

Edit: Your flow still isn't importable, it is messed up.

You are right, the TCP node outputs some kind of session ID. I think because it is different from the session ID that the TCP reply is using.

Is there a way to take this _session: part out of the message? If that works the format will be the same as the INJECT node.

image

[{"id":"8216e876.5c05c8","type":"tab","label":"Test VCOM serial server","disabled":false,"info":""},{"id":"202d55a3.441bba","type":"tcp in","z":"8216e876.5c05c8","name":"Server holding connections at :1025","server":"server","host":"192.168.5.1","port":"1025","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"text","base64":false,"x":160,"y":400,"wires":[["328f6b27.749164","c8e1dfef.00d88","79ecf549.f2f3dc"]]},{"id":"a31a50d0.5a20c","type":"tcp out","z":"8216e876.5c05c8","host":"","port":"","beserver":"reply","base64":false,"end":false,"name":"reply: all open connections will be messaged","x":970,"y":360,"wires":[]},{"id":"be5cc07b.18ac8","type":"debug","z":"8216e876.5c05c8","name":"show incomming text at the debug tab","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":890,"y":480,"wires":[]},{"id":"accb9163.6d532","type":"inject","z":"8216e876.5c05c8","name":"button: create a msg","topic":"","payload":"Hello from THE server.","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":190,"y":340,"wires":[["9aaf358.43926c8","45c64991.3fe898"]]},{"id":"328f6b27.749164","type":"template","z":"8216e876.5c05c8","name":"\"SERVER GOT:\" +","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"SERVER GOT:\n{{payload}}","x":590,"y":480,"wires":[["be5cc07b.18ac8"]]},{"id":"c8e1dfef.00d88","type":"template","z":"8216e876.5c05c8","name":"modify received msg to be send back","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"You were sending: {{payload}}\n","x":550,"y":400,"wires":[["a31a50d0.5a20c"]]},{"id":"9aaf358.43926c8","type":"template","z":"8216e876.5c05c8","name":"+ newline","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}\n","output":"str","x":600,"y":340,"wires":[["a31a50d0.5a20c"]]},{"id":"ed17bfff.14b74","type":"debug","z":"8216e876.5c05c8","name":"show incomming text at the debug tab","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","x":710,"y":860,"wires":[]},{"id":"dffec33c.659c2","type":"inject","z":"8216e876.5c05c8","name":"button: create a msg","topic":"","payload":"Hello from THE client.","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":250,"y":680,"wires":[["894499a9.3b8948"]]},{"id":"b9aa7716.cc7aa8","type":"tcp out","z":"8216e876.5c05c8","host":"","port":"","beserver":"reply","base64":false,"end":false,"name":"reply: the server will get messaged","x":820,"y":680,"wires":[]},{"id":"acd6dd95.57de9","type":"tcp in","z":"8216e876.5c05c8","name":"Node-RED Client","server":"client","host":"localhost","port":"1025","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"text2","base64":false,"x":200,"y":800,"wires":[["d0a7631.e0a1ca","fb56724d.274ed"]]},{"id":"d0a7631.e0a1ca","type":"template","z":"8216e876.5c05c8","name":"\"CLIENT GOT:\" +","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"CLIENT GOT:\n{{payload}}","x":450,"y":860,"wires":[["ed17bfff.14b74"]]},{"id":"e8324c24.d0d98","type":"comment","z":"8216e876.5c05c8","name":"Telnet client: open your command prompt, and type: `telnet localhost 1025` and start typing","info":"Telnet client: open your command prompt, and type: `telnet localhost 1025` and start typing","x":470,"y":1640,"wires":[]},{"id":"894499a9.3b8948","type":"template","z":"8216e876.5c05c8","name":"+ newline","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}}\n","output":"str","x":480,"y":680,"wires":[["b9aa7716.cc7aa8","b6237e99.e8fcf"]]},{"id":"fb56724d.274ed","type":"template","z":"8216e876.5c05c8","name":"no msg back, we do behave!","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"","x":500,"y":760,"wires":[["b9aa7716.cc7aa8"]]},{"id":"c8f799d7.262f48","type":"tcp in","z":"8216e876.5c05c8","name":"Connect to Lantronix","server":"client","host":"10.2.9.138","port":"10001","datamode":"stream","datatype":"utf8","newline":"\\n","topic":"","base64":false,"x":190,"y":200,"wires":[["9de08f5a.773e9"]]},{"id":"9de08f5a.773e9","type":"debug","z":"8216e876.5c05c8","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":430,"y":200,"wires":[]},{"id":"b6237e99.e8fcf","type":"debug","z":"8216e876.5c05c8","name":"show incomming text at the debug tab","active":false,"console":"false","complete":"payload","x":830,"y":600,"wires":[]},{"id":"d4873d8a.b768a","type":"inject","z":"8216e876.5c05c8","name":"S01,01,01,80 ","topic":"","payload":"S01,01,01,80","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":"","x":210,"y":300,"wires":[["9aaf358.43926c8","45c64991.3fe898"]]},{"id":"45c64991.3fe898","type":"debug","z":"8216e876.5c05c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":590,"y":300,"wires":[]},{"id":"79ecf549.f2f3dc","type":"debug","z":"8216e876.5c05c8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":810,"y":440,"wires":[]}]

The msg.payload coming from the tcp node is 13 characters long and ends with a space.
The msg.payload coming from the inject node is 12 characters long

maybe you want to 'trim' the space from the tcp msg.payload? the

Thanks for you reply, Yes i noticed the difference. I have to add the space to the inject or do a splitstring operation. but this is not causing the TCP issue.

I have to somehow take out the _session object.

@PiMo131 You can use a Change node to remove the _session property

That worked thanks everyone!

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