Open jczimm opened 10 years ago
Having same issue and nat-pmp has been the most promising module, all the others have failed or weren't for windows, am about to just give up, just some things not possible yet with node.js!
Is this project like most of the others dead?
@jczimm @werescape This worked for me:
var natpmp = require('nat-pmp');
...
var client = natpmp.connect("192.168.1.1");
setTimeout(function () {
client.portMapping({ private: 8070, public: 8070, ttl: 0 }, function (err, info) {
if (err) throw err;
console.log(info);
// server code
...
client.close();
});
});
As the this.socket.bind(port)
is executed twice (because it's queued till next setTimeout
) by changing the code connect
is only executed once. Probably, this can be patched so it never happens but it's a good workaround for now. Hope that helps!
I'm having this issue too, I can't seem to get it to work. I tried @pose's solution, with no luck.
dgram.js:161 - Socket Is already bound
Same problem on OS X.
I found the solution. You need to change the following
exports.CLIENT_PORT = 5352
in node-nat-pmp/Index.js to another port that's open.
There's various ports that work. I set it to 0 currently as that makes it binds to any random kernel selected port.
In addition, do not use the code from the npm install. That code is outdated. Use the index.js from this git repo.
@SkeletonSlayerz Awesome, thank you! I was able to get it working using 0 as well.
@Tillman32 Yep. Only problem with this is that it doesn't conform to the NAT-PMP standard, but it should be fine if you're only opening the port for a short amount of time.
I found Bonjour's mDNS to be of the offending nature in this case, taking up the 5352 Port on Mac. It doesn't set SO_REUSEADDR by default and therefore it turns into the only service that can bind to the port.
Any fix for this?
I'm using
nat-pmp
for my server.On Windows I get this error:
Does
nat-pmp
simply not work on Windows? Thanks!