1

I can't figure out what the error is or how to solve it.

I'm trying to run a basic code on a RPi3 from that sends an osc message to sonic pi on the same device.

this is the code:

var osc = require("osc");

var udpPort = new osc.UDPPort({
    // This is the port we're listening on.
    localAddress: "127.0.0.1",
    localPort: 4600,

    // This is where sclang is listening for OSC messages.
    remoteAddress: "127.0.0.1",
    remotePort: 4559,
    metadata: true
});

// Open the socket.
udpPort.open();

And this is the error thrown:

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

Error: bind EADDRINUSE 192.168.1.23:4559
    at dgram.js:337:20
    at processTicksAndRejections (internal/process/task_queues.js:85:21)
Emitted 'error' event on  instance at:
    at Socket.<anonymous> (/home/pi/Tools-for-Instagram/node_modules/osc/src/platforms/osc-node.js:79:18)
    at Socket.emit (events.js:327:22)
    at dgram.js:339:14
    at processTicksAndRejections (internal/process/task_queues.js:85:21) {
  errno: -98,
  code: 'EADDRINUSE',
  syscall: 'bind',
  address: '192.168.1.23',
  port: 4559
}
Blckpstv
  • 117
  • 3
  • 17

1 Answers1

0

OSC requires discrete ports for listening. What your code is doing is opening up another listening port on the same on.

Try changing this:

// This is the port we're listening on.
localAddress: "192.168.1.23",
localPort: 4559,

to this:

// This is the port we're listening on.
localAddress: "192.168.1.23",
localPort: 4600, // listening on a different port 

If both of this code is running on the same device as sonicpi you might also want to use 127.0.0.1 or localhost as the address instead of your local network address.

Adam Tindale
  • 1,239
  • 10
  • 26
  • Tried both and nothing changed. Sorry edit. The error is gone but I get nothing on sonic pi – Blckpstv May 16 '20 at 13:35
  • OK, I think this is the answer for your question. You seem to be posing a new one about transmitting messages. Your code doesn't actually send a message so you wouldn't get any response from SonicPi unless you send a message from your JS and then had something set up in SonicPi to receive that message. – Adam Tindale May 16 '20 at 18:59