Giter VIP home page Giter VIP logo

Comments (6)

alexweininger avatar alexweininger commented on September 3, 2024

Encountering the same error. I have no idea if it's related but I recently updated Windows. Here is my version:

Edition	Windows 10 Pro
Version	20H2
Installed on	‎2/‎27/‎2021
OS build	19042.1052
Experience	Windows Feature Experience Pack 120.2212.2020.0

I keep getting

Error: bind EACCES 0.0.0.0:56700

each time I try to discover.

Also my Wifi went out and came back yesterday so I think that could be the problem.

from node-lifx-lan.

illiteratealliterator avatar illiteratealliterator commented on September 3, 2024

I'm also seeing this problem (on the same build of Windows, if that's related).

Error: bind EADDRINUSE 0.0.0.0:56700
    at dgram.js:357:20
    at processTicksAndRejections (internal/process/task_queues.js:83:21) {
  errno: -4091,
  code: 'EADDRINUSE',
  syscall: 'bind',
  address: '0.0.0.0',
  port: 56700
}

Using netstat -a -p UDP I can confirm the port is closed correctly when I terminate my application. When I run it again, I get the above error when the discover() call is made. If comment out that call, I do not get the error.

Edit: I ran into this again today, and this time it was happening 100%. Again, netstat reported no applications on UDP 56700. I had a look at the library source, and it appears to be doing nothing more than dgram createSocket & bind. I tried using the "reuseAddr" option on createSocket, but it made no difference. I then closed everything down and ran a node app that did nothing other than create/bind the socket, and it failed just the same. I was able to bind other ports without any problems. I then rebooted my machine and upon restart I was able to bind 56700 without problem. I suspect this has nothing to do with the node-lifx-lan library, and more likely just windows handling closing ports badly.

from node-lifx-lan.

dresende avatar dresende commented on September 3, 2024

Looking at the code, the resolution is simple. The problem is that .init() initializes an UDP socket if not initialized yet, but this process takes a few milliseconds out of event loop, so if you call createDevice more than once in a row it will throw.

You need to start using module like:

const Lifx = require("node-lifx-lan");

Lifx.init().then(() => {
    // now you can discover, create devices, etc..
})

from node-lifx-lan.

illiteratealliterator avatar illiteratealliterator commented on September 3, 2024

Thanks @dresende, but OP is already calling discover().then (which internally calls init().then) and I'm calling await Lifx.init() before using the library at all. I'm pretty sure this is unrelated to the Lifx library, but rather Windows socket handling.

from node-lifx-lan.

dresende avatar dresende commented on September 3, 2024

Thanks @dresende, but OP is already calling discover().then (which internally calls init().then)

But if I call .createDevice twice in the same event, init() will not finish and be called twice, trying to bind the UDP socket twice.

I'm pretty sure this is unrelated to the Lifx library, but rather Windows socket handling.

You're wrong. I'm on macOS and had the same problem, that's why I came here. And I solved it by doing just that.

from node-lifx-lan.

illiteratealliterator avatar illiteratealliterator commented on September 3, 2024

If you don't wait for init() to complete before calling createDevice multiple times, then you will absolutely run into this error. However, I always wait for init() to complete before calling any other library function, and I'm saying that the issue I was seeing appeared to be Windows specific.

from node-lifx-lan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.