hobbyquaker/lgtv2

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

Zibri opened this issue · 3 comments

Zibri commented

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

I don't understand why.

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?

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