hobbyquaker / lgtv2

Control LG WebOS TV using node.js :tv:
MIT License
332 stars 45 forks source link

It works but in a function doesn't work...why? #16

Closed Zibri closed 6 years ago

Zibri commented 6 years ago

This does not work!

addr="10.42.0.235";
lgtv=require("lgtv2")({url: 'ws://' + addr + ':3000'});  
lgtv.on('connect', function () {
    console.log('connected');
    lgtv.request('ssap://audio/setVolume','{"volume": 0}', function (err, res) {
        console.log(res,err);
        lgtv.disconnect();
        process.exit(1);
    });

});

This works:

addr="lgtv";  //lgtv = 10.42.0.235 in /etc/hosts
lgtv=require("lgtv2")({url: 'ws://' + addr + ':3000'});  
lgtv.on('connect', function () {
    console.log('connected');
    lgtv.request('ssap://audio/setVolume','{"volume": 0}', function (err, res) {
        console.log(res,err);
        lgtv.disconnect();
        process.exit(1);
    });

});
Zibri commented 6 years ago

I don't understand why.

hobbyquaker commented 6 years ago

The only difference i see is addr 10.42.0.235 vs. lgtv. So this is quite sure an issue with you dns resolution. Perhaps your client appends a search suffix and that's the reason why your entry in /etc/hosts doesn't help? Can you resolve the name with e.g. nslookup? what's in /etc/resolv.conf?

hobbyquaker commented 6 years ago

Ah. I think I got you wrong ;-) It works with the Hostname but not with the IP Address? Hmm. Strange...