CharlesHolbrow / monode

Monome/Arc toolkit in node.js
MIT License
18 stars 2 forks source link

ERROR: Failed to listen on udp port 4545. Is node-monome already running?' #4

Closed CharlesHolbrow closed 7 years ago

CharlesHolbrow commented 10 years ago

We get this error when a slow synchronous process occurs immediately after initing monode -- even when monode is NOT already running. This happens because if an message is not received in 20ms, my osc implementation assumes that it never will be received, and the udp port is unavailable.

A simple solution is just increasing the 20ms timeout, but there's probably a better way.

kaosbeat commented 10 years ago

ok...

not really that good in waiting longer then 20ms, call me impatient, but I'd rather say it's because I don't know how to increase the timeout...

running it on the raspberry pi probably does not improve my chances of getting a reply in 20ms

K

CharlesHolbrow commented 10 years ago

Did you experience this bug on the Raspberry Pi? Can you show me the code?

Keep in mind that the 20ms timeout only occurs when the udp port that we opened is not available -- otherwise, we only wait until we receive a message on the port ensuring that it is open.

I also did not like the arbitrary 20ms timeout... so I changed how device detection works. See the current version here:

https://github.com/CharlesHolbrow/monode/blob/d5323c386b444132c64bfb055691036b4aff1a01/src/lib/osc.coffee#L21-L22

There are two 5ms timeouts. After these callbacks execute, we assume that the udp port is in use. I'm not 100% satisfied with this approach, but generally, I do think it's good to ensure that ports are available before using them. Perhaps a good compromise is passing in an optional timeout parameter when we instantiate monode.

kaosbeat commented 10 years ago

the code is the simples possible instantiation of your lib (I think):

monode = require('monode')();

works on the CLI, not in a file (as in $ node monomeapp.js) the error being the above title

Kasper

CharlesHolbrow commented 10 years ago

Hrm. okay, this is a little difficult for me to test -- since I don't have a RPi -- I'm going to try to borrow one though, so I can sort it out. In the mean time, I suspect that the code after the line you posted is interfering with the detection process. Can you try running a file with just this line, and no others

monode = require('monode')();

Also, just to double check, are you definitely running monode version 2.2.3?

kaosbeat commented 10 years ago

Hey I tried portforwarding my RPi to the outside internet, but no luck so far, so you could test it yourself.

what I did was exactly the thing you asked me to try, just that line... if I 'npm install monode', I should get the latest version right? but I'll doublecheck tonight

kaosbeat commented 10 years ago

hmmm, certainly 2.2.3...

pi@raspberrypi ~/223test $ npm install monode
npm http GET https://registry.npmjs.org/monode
npm http 304 https://registry.npmjs.org/monode
npm http GET https://registry.npmjs.org/node-osc/0.2.1
npm http 304 https://registry.npmjs.org/node-osc/0.2.1
npm http GET https://registry.npmjs.org/osc-min/0.0.5
npm http GET https://registry.npmjs.org/jspack/0.0.1
npm http 304 https://registry.npmjs.org/osc-min/0.0.5
npm http 304 https://registry.npmjs.org/jspack/0.0.1
npm http GET https://registry.npmjs.org/coffee-script/1.3.0
npm http GET https://registry.npmjs.org/binpack
npm http 200 https://registry.npmjs.org/coffee-script/1.3.0
npm http GET https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.0.tgz
npm http 304 https://registry.npmjs.org/binpack
npm http 200 https://registry.npmjs.org/coffee-script/-/coffee-script-1.3.0.tgz
npm http GET https://registry.npmjs.org/bindings
npm http 304 https://registry.npmjs.org/bindings

> binpack@0.0.14 install /home/pi/223test/node_modules/monode/node_modules/node-osc/node_modules/osc-min/node_modules/binpack
> node-gyp rebuild

make: Entering directory `/home/pi/223test/node_modules/monode/node_modules/node-osc/node_modules/osc-min/node_modules/binpack/build'
  CXX(target) Release/obj.target/binpack/src/binpack.o
  SOLINK_MODULE(target) Release/obj.target/binpack.node
  SOLINK_MODULE(target) Release/obj.target/binpack.node: Finished
  COPY Release/binpack.node
make: Leaving directory `/home/pi/223test/node_modules/monode/node_modules/node-osc/node_modules/osc-min/node_modules/binpack/build'
monode@2.2.3 node_modules/monode
└── node-osc@0.2.1 (jspack@0.0.1, osc-min@0.0.5)

pi@raspberrypi ~/223test $ serialoscd 
serialosc [m128-121]: connected, server running on port 15757

vi test.js
monode = require('monode')();
"test.js" [New] 1L, 30C written     

pi@raspberrypi ~/223test $ node test.js 
can't decode incoming message: Failed to listen on udp port 4545. Is node-monome already running?
can't decode incoming message: Failed to listen on udp port 4545. Is node-monome already running?
CharlesHolbrow commented 10 years ago

Not working on the Rasp. Pi.

CharlesHolbrow commented 7 years ago

Closing this. Please re-submit if this this is still an issue in v3.0.1