Please fix the TCP Output Node.
The TCP Output requires special consideration if you need to append the sent string with control characters. You apparently need a function node in your flow to fix the apparent problem. If it is not going to be addressed, then it needs to have a reference in the "Info Tab". This has been an known issue since at least 11/15/2015.
Kind Regards,
Kyle Young
"Nick O'Leary, 11/15/15
The inject node does handle escape sequences like \n - it treats them as literal strings.
For now, use a Function node after your Inject node to append the newline:
msg.payload = msg.payload + '\n';
return msg;
Nick"
The TCP Output node does handle them as if you add them in a function it works...
As Mark says, there is nothing to fix here. The TCP out node sends what it is given.
There are multiple ways to append a newline character - but the 'string' type of the Inject node isn't one of them.
Nick,
OK, I understand. I guess I just misunderstood your comment which I quoted you saying... "For now, use a Function node...". I apparently misinterpreted your comment as there were planned changes ahead for this matter. Also, if there are no further changes planned... Please update the "Info Tab" such that it explains you cannot use (\r\n) escape characters in your string. There is literally no feedback from the node information so it is difficult to know what is wrong if your system is expecting something specific. I tried exposing the message, but nothing was on the output of the TCP Request node...
Thanks,
Kyle
The Inject node's help says:
But yes, that certainly can be improved.
ukmoose,
I got it to work using Nicks information in the quotes. Thus, I used a function to support the control characters... Yes, My point is not that you can get it to work with this work-around, which is all fine, but please either do one of the following.
- Fix it such that you can put the control codes in the node itself...
- Edit the "Info Tab" to let people know that you will not be able to put the control characters in your string to the msg.Payload....
Nick,
you are the man !
Thank you for your kind and patient response.
Kyle
It's too bad I did not look in the injection node help for the answers.. I'm glad that's there, by-the-way.. although I had no idea it was an injection issue until I found your quote.
Hey, I'm just trying to point out a potential problem and help the users.. I wasted a long time trying to get this work. I should have googled it earlier, but I thought it would be easier. I'm not trying to criticize you guys. I am really very happy with what this does for me.
Kyle
@tree-frog BTW, the function
node is no longer your only choice. You can use a change
node to insert control characters into a payload.
1 Like
You can also use an inject node with the JSON data type:
"mystring\n" works great...
3 Likes
Thanks man! Spent an hour or two seeking, this is the goods.
1 Like