I'm trying to send an osc-message from Firefox using javascript, which should be received by another computer in the same network using udpreceive and unpackOSC from the mrpeach library in Pure Data. I'm working with the javascript-package "osc-js" (https://github.com/adzialocha/osc-js). I have three instances:
- a html file with javascript included, that sends the message from the sending computer
- a bridge that runs on nodejs an creates a websocket server on the receiving computer
- a Pure Data patch that should receive the message
1.
<button id="send">Send Message</button>
<script type="text/javascript" src="https://cdn.jsdelivr.net/gh/adzialocha/osc-js/lib/osc.js"></script>
<script type="text/javascript">
var osc = new OSC();
osc.open({host:'130.149.23.228', port: '9111'}) //connect to server that was created by the bridge
document.getElementById('send').addEventListener('click', () => {
var message = new OSC.Message('/test/', 2);
osc.send(message); //send message on click
});
</script>
2.
const OSC = require('osc-js')
const config = { udpClient: { port: 9912 } }
const osc1 = new OSC({ plugin: new OSC.BridgePlugin(config) })
osc1.open({host:'130.149.23.228', port:'9111'}) // start a WebSocket server on port 8080
The sending computer runs on Windows, the receiving one on Linux. Sending OSC from Pure Data (PC1) to Pure Data (PC2) works. It also works to send and receive inside one PC from Browser to Pure Data via localhost. But now I get this error in Firefox:
"Firefox can't establish a connection to the server on ws://130.149.23.228:9111/"