# String type difference

**URL:** <https://discourse.nodered.org/t/string-type-difference/38779>\
**Category:** General\
**Created:** [8 January 2021 10:39 UTC](https://discourse.nodered.org/t/string-type-difference/38779 "2021-01-08T10:39:46Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)\
**Post date:** [8 January 2021 10:39 UTC](https://discourse.nodered.org/t/string-type-difference/38779/1 "2021-01-08T10:39:46Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/6/e674e1fd1bcea5f115734426a39310df5b2d538e.png)  
The reply to TCP only works with the 'inject' node.

This is my flow:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/7/c75a20209835ace6991db207d42b088f19698a0e.png)

Is there a difference between the string types?

---

<div class="post-metadata">

**Author:** ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)\
**Post date:** [8 January 2021 10:57 UTC](https://discourse.nodered.org/t/string-type-difference/38779/2 "2021-01-08T10:57:06Z")

</div>

here is the full flow

```auto
`[{"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":[]}]`

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 January 2021 10:58 UTC](https://discourse.nodered.org/t/string-type-difference/38779/3 "2021-01-08T10:58:33Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)\
**Post date:** [8 January 2021 11:12 UTC](https://discourse.nodered.org/t/string-type-difference/38779/4 "2021-01-08T11:12:54Z")

</div>

Thanks Colin!

is this a better cut:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/4/641fb2b620cf0c0f9870be2e8989003042fb6495.png)

or this:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/2/22bae51182812a026f2fdfcb0d3df5577da7f6a8.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [8 January 2021 11:25 UTC](https://discourse.nodered.org/t/string-type-difference/38779/5 "2021-01-08T11:25:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)\
**Post date:** [8 January 2021 11:38 UTC](https://discourse.nodered.org/t/string-type-difference/38779/6 "2021-01-08T11:38:59Z")

</div>

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](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/4/d4e6254b1a2c35b1d301a930497465f8cfa31341.png)

---

<div class="post-metadata">

**Author:** ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)\
**Post date:** [8 January 2021 11:39 UTC](https://discourse.nodered.org/t/string-type-difference/38779/7 "2021-01-08T11:39:56Z")

</div>

```auto
[{"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":[]}]

```

---

<div class="post-metadata">

**Author:** ![zenofmud](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/zenofmud/32/316_2.png) [@zenofmud](https://discourse.nodered.org/u/zenofmud)\
**Post date:** [8 January 2021 11:47 UTC](https://discourse.nodered.org/t/string-type-difference/38779/8 "2021-01-08T11:47:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)\
**Post date:** [8 January 2021 11:49 UTC](https://discourse.nodered.org/t/string-type-difference/38779/9 "2021-01-08T11:49:38Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [8 January 2021 11:56 UTC](https://discourse.nodered.org/t/string-type-difference/38779/10 "2021-01-08T11:56:54Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![PiMo131](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/pimo131/32/34978_2.png) [@PiMo131](https://discourse.nodered.org/u/PiMo131)\
**Post date:** [8 January 2021 12:27 UTC](https://discourse.nodered.org/t/string-type-difference/38779/11 "2021-01-08T12:27:09Z")

</div>

That worked thanks everyone!

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/e/bea5a053a79ba1b0f62e045b49f884da5fdd71ff.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 March 2021 12:27 UTC](https://discourse.nodered.org/t/string-type-difference/38779/12 "2021-03-09T12:27:13Z")

</div>

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