# Sending data with tcp out node

**URL:** https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534
**Category:** General
**Created:** [2 July 2023 08:29 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534 "2023-07-02T08:29:50Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Muschelpuster](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Muschelpuster](https://discourse.nodered.org/u/Muschelpuster)
#### Post date: [2 July 2023 08:29 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/1 "2023-07-02T08:29:50Z")

</div>

I try to build a very tiny LDAP-service to learn much about LDAP and the structure of ASN.1 coded IP packages. I receive a bind request over the 'tcp in' node and can read all necessary information (user, password, session-id). But now I'm sticking by responding with the bind response. I create the response in the same format as I received the in-message (buffer raw with an array of hex values) and call the 'tcp out' node. Here I selected 'respond to TCP'. And as I can see at wireshark the answer is sent, but only 6 values with 0x00 and not my 14 values from msg.payload.buffer. Can anyone tell me how I can fix it? The help of the node only tells me, that the content of the payload will send out and msg.\_session is needed for responding, which I can see in debugging.

Niels

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [2 July 2023 08:31 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/2 "2023-07-02T08:31:56Z")

</div>

> [@Muschelpuster](#):
>
> msg.payload.buffer

I'm fairly certain it is mentioned in the built-in help on the side bar, your data needs to be in `msg.payload` not `msg.payload.buffer`

---

<div class="post-metadata">

### Author: ![Muschelpuster](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Muschelpuster](https://discourse.nodered.org/u/Muschelpuster)
#### Post date: [2 July 2023 08:35 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/3 "2023-07-02T08:35:48Z")

</div>

Thank you Steve,

this is a mistake at my post. I create it with a function by this code:

```auto
var b=Buffer.from([48,13,2,1,msg.msgID,97,7,10,1,0,4,0,4,0])
msg.payload=b
return msg;

```

Niels

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [2 July 2023 08:38 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/4 "2023-07-02T08:38:45Z")

</div>

Add a debug node just before the TCP out node & verify what you believe you are sending is correct.

Ps set the debug to show complete message

---

<div class="post-metadata">

### Author: ![Muschelpuster](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Muschelpuster](https://discourse.nodered.org/u/Muschelpuster)
#### Post date: [2 July 2023 09:03 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/5 "2023-07-02T09:03:05Z")

</div>

I did it already and it looks nice for me:

 ![Screenshot 2023-07-02 110154](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57a08dd15ddd3d7fb3089e4831dba05bac8183ea.png)

Niels

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [2 July 2023 09:32 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/6 "2023-07-02T09:32:45Z")

</div>

How have you setup the TCP nodes?

Tip: if you knock up a small demo flow that sends sample data using a TCP request node and share that, someone will try it out and help you.

Also, please list version numbers and environment (node version? Node-red version? Docker install? Behind proxy? Part of home assistant? Linux/Mac/windows? Etc)

---

<div class="post-metadata">

### Author: ![Muschelpuster](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Muschelpuster](https://discourse.nodered.org/u/Muschelpuster)
#### Post date: [2 July 2023 10:21 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/7 "2023-07-02T10:21:18Z")

</div>

Node-red is running at my raspberryPI with Raspbian old-stable.

```auto
pi@raspberrypi:~ $ uname -a
Linux raspberrypi 5.10.17-v7+ #1403 SMP Mon Feb 22 11:29:51 GMT 2021 armv7l GNU/Linux

```

Everything runs on my local (W)LAN without proxy etc.. Node-Red is V.1.2.9 (oh, very old, I will search, why it‘s not updated - maybe because it’s installed from Raspbian DEBs…)  
Received data is:

```auto
[48,132,0,0,0,26,2,2,0,168,96,132,0,0,0,16,2,1,3,4,4,105,99,104,49,128,5,49,50,51,97,98]

```

Payload from debug before sending the response is:

```auto
[48,13,2,1,168,97,7,10,1,0,4,0,4,0]

```

I will share the whole flow, stripping it down will create new errors. It's not a high art, it's created with my low knowledge level to learn. Have mercy on me 😉  
[flows.json](https://discourse.nodered.org/uploads/short-url/3kHaZZaN0YmRzDazdFrJPzsE5sh.json) (6.4 KB)

Niels

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [2 July 2023 11:12 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/8 "2023-07-02T11:12:03Z")

</div>

> [@Muschelpuster](#):
>
> Node-Red is V.1.2.9

This would definitely be where I start. That is looking out of support

See here: [Running on Raspberry Pi : Node-RED](https://nodered.org/docs/getting-started/raspberrypi#installing-and-upgrading-node-red)

Also, be sure to add ` --node16` or `node18` to the end of the update script - to update node.js at the same time as installing V3.0.2

---

<div class="post-metadata">

### Author: ![Muschelpuster](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Muschelpuster](https://discourse.nodered.org/u/Muschelpuster)
#### Post date: [2 July 2023 14:01 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/9 "2023-07-02T14:01:31Z")

</div>

Now everything is up to date. Node-Red V.3.0.2, node.js 18 and actual Raspbian. And at update time I found out that this was not the problem (but it's fine, that I did this). I looked at the false packet at Wireshark! Also at the old trace, the answer was going out, but I analysed the TCP-ACK-Paket. Blame on me ☹ One packet later my message is going out but it will not interpret as LDAP package by Wireshark and also not by the client. So I have to find out what's wrong with my packet...

Niels

---

<div class="post-metadata">

### Author: ![Muschelpuster](https://avatars.discourse-cdn.com/v4/letter/m/b3f665/32.png) [@Muschelpuster](https://discourse.nodered.org/u/Muschelpuster)
#### Post date: [2 July 2023 15:57 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/10 "2023-07-02T15:57:15Z")

</div>

It works so far. I can bind my client (by ignoring a lot of information) successfully. Thanks for your support, Steve!  
I'm not a great artist at programming, but if someone needs some input for similar things here is my flow so far:  
[tinyLDAP.json](https://discourse.nodered.org/uploads/short-url/wZlySnruk5GMTf8byiMEMuBJCbI.json) (6.3 KB)  
I'm every time glad by finding such snippets. If someone wants to optimize it - feel so free.  
There are some unnecessary things in the flow (e.g. calculating the message ID) but I keep it right now - maybe I need it later.  
In conclusion, the main problem was not the version, it was (like mostly) on the human side. I inspected the wrong packet at Wireshark and got confused by this. But so my installation is up to date - what a nice side effect 😉

Niels

---

<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: [16 July 2023 15:57 UTC](https://discourse.nodered.org/t/sending-data-with-tcp-out-node/79534/11 "2023-07-16T15:57:53Z")

</div>

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