Saturday 18 March 2017

sending OSC between machines on a LAN using Node.js and OSC.js

Has anyone created a working setup where OSC is being sent between machines on a LAN using Node.js? Ideally, using Colin Clark's osc.js package?

I have what I think should be a pretty simple example, except that it doesn't work - I get an EADDRNOTAVAIL error, which implies that the remote address isn't available. I can ping the other laptop successfully, however.

Here's the code and the error, for reference:

Sending code (laptop at 192.168.0.5):

var osc = require("osc");

var udp = new osc.UDPPort({
    localAddress: "127.0.0.1", // shouldn't matter here
    localPort: 5000, // not receiving, but here's a port anyway
    remoteAddress: "192.168.0.7", // the other laptop
    remotePort: 9999 // the port to send to
});

udp.open();

udp.on("ready", function () {

    console.log("ready");
    setInterval(function () {
        udp.send({
            address: "/sending/every/second",
            args: [1, 2, 3]
        })
    }, 1000);
});

Receive code (on laptop at 192.168.0.7):

var osc = require("osc");
var udp = new osc.UDPPort({
    localAddress: "192.168.0.7",
    localPort: 9999
});

udp.open();

udp.on("ready", function () {
    console.log("receiver is ready");
});

udp.on("message", function(message, timetag, info) {
   console.log(message); 
});

Here's the error I get when I run the sending code:

ready
events.js:141
      throw er; // Unhandled 'error' event
      ^

Error: send EADDRNOTAVAIL 192.168.0.7:9999
    at Object.exports._errnoException (util.js:907:11)
    at exports._exceptionWithHostPort (util.js:930:20)
    at SendWrap.afterSend [as oncomplete] (dgram.js:345:11)



via jwn

No comments:

Post a Comment