From ncat to "tcp nodes"

Hi all,
To communicate informations to a server I use cron and ncat as below :
printf "MY MESSAGE HERE" | ncat HOST PORT

You understood me : today I wish to be able to do it from NodeRed ... but I am still unable to do it :frowning:
I tried with "tcp out" : I am well connected to the server (green) but do not succeed in making him understand my message !
(I also tried tcp-client (I did receive a return from the server but I did not succeed in having my request taken into account)

thanks for your advices :wink:
Isea

If you simply want to send a message to node-red from the command line, you could execute mosquito_pub to send MQTT message to a broker. Then node-red can easily subscribe to the topic and listen for your events.

This will avoid the issues with TCP port lockups, re-formatting the incoming data etc.

thank you very much @Steve-Mcl for this prompt response :slight_smile:

but I misspoke : the site on which I have to send a message (which contains my username + password and then followed by the info to communicate) does not belong to me and does not offer mqtt)

To be precise and since there is nothing secret, it is with this site for hams that I want to communicate using NodeRed : http://www.aprs2.net
(I use port 14580 with ncat http://www.aprs-is.net/javAPRSSrvr/ports.aspx )

Even more precisely here is what ... does not work !

[{"id":"4d2fbef0.37b18","type":"function","z":"9a73099a.b66008","name":"A2","func":"msg.payload = \"My_message\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":140,"y":480,"wires":[["204940b8.053148"]]},{"id":"204940b8.053148","type":"join","z":"9a73099a.b66008","name":"Join A1 and A2","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":"\" \"","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":480,"y":340,"wires":[["4262ab76.f45e3c","f87bf977.e86ad8"]]},{"id":"68cde1fd.13c5b8","type":"test","z":"9a73099a.b66008","name":"","escapeString":false,"infiniteIsNull":false,"payload":"","payloadType":"num","result":"","resultType":"date","resultProperty":"msg.payload","topic":"","x":150,"y":380,"wires":[["4d2fbef0.37b18"],[],[]]},{"id":"4262ab76.f45e3c","type":"debug","z":"9a73099a.b66008","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":810,"y":340,"wires":[]},{"id":"f87bf977.e86ad8","type":"tcp out","z":"9a73099a.b66008","host":"host.net","port":"12345","beserver":"client","base64":false,"end":false,"name":"","x":670,"y":400,"wires":[]},{"id":"457118e6.f6f0f8","type":"function","z":"9a73099a.b66008","name":"A1","func":"msg.payload = \"user xxx pass xxx\";\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":150,"y":220,"wires":[["204940b8.053148"]]},{"id":"255126a2.0eee6a","type":"test","z":"9a73099a.b66008","name":"","escapeString":false,"infiniteIsNull":false,"payload":"","payloadType":"num","result":"","resultType":"date","resultProperty":"msg.payload","topic":"","x":150,"y":300,"wires":[["457118e6.f6f0f8"],[],[]]}]

I don't understand:
at least "visually" it's the same as when I ordered using ncat?

printf "%s\n" "user xxxx pass xxxx" "My_message" | ncat host.net 12345

So there is an important difference between "ncat" and "node tcp-out" that escapes me?

I doubt you are transmitting the correct format and additionally, not knowing the process ncap does under the hood, there may well be a number of things going on (e.g. ncap possibly encrypts username/password, formats the data for transmission, might even do some handshaking before transmitting payload.)

Run wireshark (or tcpdump) to see the difference in data transmissions to/from port 12345 when using ncap vs tcp node.

Yes, a lot of unknowns and besides I lack the basics about networks :frowning:
thank you @Steve-Mci for wireshark that I did not know: I have work for ... years !!!

But I also lack the basics of programming ... and I just found the source of my problem: bad formatting of my frames!
I added a "\ n" at the end and everything is solved :slight_smile:
If writing it here may be useful for another beginner, so much the better !

2 Likes

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