Title: Node.js OSC Module send TCP
Tags: javascript;node.js;sockets;tcp;osc
Question: I am using the OSC module https://github.com/colinbdclark/osc.js but I am struggling to get it to work over TCP.  I am unable to find any examples that use TCP, they are all based on UDP.
I have tried just creating a TCP client in node.js but still struggle to get the message encoded correctly into OSC format.  I also believe it has to be encoded with SLIP as well?
I am very new at this so be gentle.
Would be amazing if someone could please point me in the right direction  or provide an example about sending OSC messages via TCP in node.js
Thank you!
PS. Happy to use osc-min module as well. As I know with that you can encode the message to an osc message and store in a var. But still can't get it to work over TCP .. works fine over UDP but my replys are larger than the what UDP can handle if that makes sense

Here is the accepted answer: I'm not very familiar with OSC, so I don't know about its internals, but osc.js does support TCP transport, like this:
let server = new osc.TCPSocketPort({});
server.open('151.154.11.224', 57121); // change to remote host/port
server.on('ready', () =&gt; {
console.log('ready');
According to the README:
For stream-based protocols such as serial and TCP, osc.js will take care of SLIP framing for you.
Comment for this answer: Thanks so much. Currently on a train and laptop is flat. But I will try later on tonight. I couldn't find an example of how to use it via TCP but judging by yours, I was getting closer ;) will let you know asap.
Comment for this answer: amazing! works one i changed it from server as that is already defined...now i get the replies using -
let tcpServer = new osc.TCPSocketPort({});
tcpServer.open('151.154.11.224', 53000);
tcpServer.send({
address: "/version",
args: 1,
}, '151.154.11.224', 53000);
tcpServer.on('data', function(data) {
console.log('DATA: ' + data);
But the reply in console isn't quite the same as a UDP message
�/reply/version,s{"status":"ok","address":"\/version","data":"4.0.6"}�
Normally I would access this via data.status to get status value.
Comment for this answer: of course, i used the same method as the working UDP replies tcpServer.on('message', function(oscBundle, timeTag, info) {
console.log('Message: ' + oscBundle.args);
});  Thank you very much for your help!!
Comment for this answer: @Wayde I don't have an OSC server to test against, but it looks like you're getting the raw packet data there. Because of the SLIP framing, it might be that you need to unpack the data first. Instead of listening for the `data` event, try listening for the `message` event (FWIW, I'm piecing all this together from the [`osc.js`](https://github.com/colinbdclark/osc.js) source and [it's example repository](https://github.com/colinbdclark/osc.js-examples)).


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:03/07/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<javascript><node.js><sockets><tcp><osc>', 'Title': 'Node.js OSC Module send TCP', 'ViewCount': 613, 'id': 42658547, 'user_AboutMe': '', 'user_AccountId': 2804901.0, 'user_DisplayName': 'Wayde', 'user_Reputation': 53.0, 'user_Views': 9.0, 'user_id': 2412337.0}}