diff --git a/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js b/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js
index a3cafd141..e49405634 100644
--- a/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js
+++ b/packages/node_modules/@node-red/nodes/core/network/31-tcpin.js
@@ -517,6 +517,7 @@ module.exports = function(RED) {
this.port = Number(n.port);
this.out = n.out;
this.ret = n.ret || "buffer";
+ this.newline = n.newline;
this.splitc = n.splitc;
if (n.tls) {
var tlsNode = RED.nodes.getNode(n.tls);
@@ -802,7 +803,7 @@ module.exports = function(RED) {
if (clients[connection_id].client) {
clients[connection_id].connecting = true;
- var connOpts = {host: host, port: port};
+ var connOpts = {host:host, port:port};
if (n.tls) {
connOpts = tlsNode.addTLSOptions(connOpts);
}
diff --git a/test/nodes/core/network/31-tcprequest_spec.js b/test/nodes/core/network/31-tcprequest_spec.js
index dc0755c1b..532e870bd 100644
--- a/test/nodes/core/network/31-tcprequest_spec.js
+++ b/test/nodes/core/network/31-tcprequest_spec.js
@@ -84,9 +84,17 @@ describe('TCP Request Node', function() {
n2.on("input", msg => {
try {
if (typeof result === 'object') {
- msg.should.have.properties(Object.assign({}, result, {payload: Buffer.from(result.payload)}));
+ if (flow[0].ret === "string") {
+ msg.should.have.properties(Object.assign({}, result, {payload: result.payload}));
+ } else {
+ msg.should.have.properties(Object.assign({}, result, {payload: Buffer.from(result.payload)}));
+ }
} else {
- msg.should.have.property('payload', Buffer.from(result));
+ if (flow[0].ret === "string") {
+ msg.should.have.property('payload', result);
+ } else {
+ msg.should.have.property('payload', Buffer.from(result));
+ }
}
done();
} catch(err) {
@@ -245,10 +253,23 @@ describe('TCP Request Node', function() {
}, done);
});
+ it('should send & receive, then keep connection, and split return strings', function(done) {
+ var flow = [{id:"n1", type:"tcp request", server:"localhost", port:port, out:"sit", ret:"string", newline:"", wires:[["n2"]] },
+ {id:"n2", type:"helper"}];
+ testTCPMany(flow, [{
+ payload: "foobar",
+ topic: 'boo'
+ }], {
+ payload: "ACK:foo",
+ topic: 'boo'
+ }, done);
+ });
+
it('should send & recv data to/from server:port from msg', function(done) {
var flow = [{id:"n1", type:"tcp request", server:"", port:"", out:"time", splitc: "0", wires:[["n2"]] },
{id:"n2", type:"helper"}];
- testTCPMany(flow, [{
+ testTCPMany(flow, [
+ {
payload: "f",
host: "localhost",
port: port