Closed PSeitz closed 10 years ago
The server portion needs the SO_BROADCAST
flag set, so commenting it out isn't a good idea.
The only way I know of that setBroadcast()
can fail with EBADF
is if the file descriptor is bad -- i.e., the socket was not bound. If the socket was not bound, the callback should not have been called. Perhaps @trevnorris or @bnoordhuis know how this could possibly happen with the following code:
var _this = this;
this.server.bind(67, host, function() {
_this.server.setBroadcast(true);
});
Based upon the docs, I was under the assumption that if any error occured, either bind()
would throw (rare case), or the error
event would be fired, but in neither case would the callback be called.
What does strace -fe \!mmap,munmap,mprotect,brk,futex,gettimeofday,clock_gettime node script.js
print? You can redirect the output to a log file with -o filename
if there's too much of it. Is there a LSM like AppArmor or SELinux active on the system?
Last but not least, can you post the output of uname -a
and node -p process.versions
?
The error disappeared so I cannot trace the error. The system is vanilla, nothing except nodejs is installed. If it is a file handle, then maybe the sd-card is broken.
Just for reference:
uname -a
Linux raspberrypi 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 armv6l GNU/Linux
node -p process.versions
{ http_parser: '1.0',
node: '0.10.28',
v8: '3.14.5.9',
ares: '1.9.0-DEV',
uv: '0.10.27',
zlib: '1.2.3',
modules: '11',
openssl: '1.0.1g' }
I get that error below on my raspberry pi. It works when I uncomment this line in server.js 37: _this.server.setBroadcast(true);
dgram.js:348 throw errnoException(process._errno, 'setBroadcast'); ^ Error: setBroadcast EBADF at errnoException (dgram.js:457:11) at Socket.setBroadcast (dgram.js:348:11) at Server.bind (/home/pi/HomeAutomation/node_modules/dhcpjs/lib/server.js:31:17) at Object. (/home/pi/HomeAutomation/dhcp_callback_module.js:31:8)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)