colinbdclark / osc.js

An Open Sound Control (OSC) library for JavaScript that works in both the browser and Node.js
GNU General Public License v2.0
777 stars 117 forks source link

Browser UDP not communicated on remote computer #178

Open KonVas opened 3 years ago

KonVas commented 3 years ago

I am working on a NodeJS/Express app.

I have this addresses below and while WebSocket works okay on the host machine, when running my app on another computer connected to the local network the message is not send to SC on its local SC of the remote computer, though is send to the host computer running Node/Server. That said, this is something I want, to get all OSC from all devices running the app but I would also think that the osc mesages are also bind to their local SC? Or I am missing out something trivial here.

Unless this is expected, I am speculating that I only receive the osc msgs because of the IP address in use below.

Client code

//OSC UDP-Browser Configuration
oscPort = new osc.WebSocketPort({
url: "ws://192.168.1.104:8081", 
//tested with 127.0.0.1, and 0.0.0.0 throws "connection refused" error in both cases.
metadata: true
})

Server code


const osc = require('osc'),
WebSocket = require('ws');

let udp = new osc.UDPPort({ // This is the port we're listening on. localAddress: "0.0.0.0", localPort: 57121, // This is where sclang is listening for OSC messages. remoteAddress: "0.0.0.0", remotePort: 57120 })

var wss = new WebSocket.Server({ port: 8081 })



My server runs on 192.168.1.104:8000 if that makes any difference. For what's worth,  I can receive the osc msg in all computers one way (SC - Browsers). I have checked for firewall or something else blocking  on the corresponding computer but it's deactivated.

Thanks for all work it's fantastic, and the examples are very meticulously conducted.
ahfontaine commented 3 years ago

Hi KonVas, I am currently struggling with the same issue, did you ever find a solution to this problem?

KonVas commented 3 years ago

I probably did, I was messing up the addresses in. Below is my working code:

let udp = new osc.UDPPort({

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

// This is where sclang is listening for OSC messages.
remoteAddress: "127.0.0.1",
remotePort: 57120
})