msloth / lgtv.js

Control LG WebOS TV using node.js
MIT License
249 stars 119 forks source link

unable to connect #2

Closed avenantsoftware closed 8 years ago

avenantsoftware commented 8 years ago

I get an error:

Connect Error: Error: getaddrinfo ENOTFOUND lgsmarttv.lan lgsmarttv.lan:3000

Does it matter if the TV is connected through lan or wifi? because my tv is connected trough wifi to my local network

msloth commented 8 years ago

It shouldn't matter as long as you are on the same LAN (ethernet or wifi).

I guess the reason you can't connect is either you haven't enabled zeroconf/bonjour/local network discovery in your TV, or, the TV advertises itself under a different name. This should be made dynamic, looking it up instead of a hardcoded name, but it works well for me and this project is borderline abandoned. PR's on this issue are appreciated.

Check the above and get back if it doesn't work. Will close the issue otherwise in a while.

avenantsoftware commented 8 years ago

I have no zeroconf/bonjour setting on my tv but can set the name for the tv in the network to lgsmarttv.lan, also if I use the lg remote android app it finds my tv as lgsmarttv.lan. so it must be configured correctly, why would the android app otherwise find it as lgsmarttv.lan? also: sudo nmap -sV -p 1-65535 192.168.2.6 works

msloth commented 8 years ago

The nmap command will just scan the TV for ports open and try to identify services behind open ports and doesn't indicate whether you have enabled the mDNS service. I'll have a look at exactly what the setting is called and update the readme and this thread soon.

msloth commented 8 years ago

Yeah, the only setting I have is to allow LG Connect apps. That should be it. Honestly, I don't remember where the lgsmarttv.lan come from as I can't find any references to it in the TV now. You can set a name but mine isn't that, and it still works. Perhaps it got reset at some point but my router still has it cached? Don't know. Look at my answer to issue #1 , I will make it autodetecting instead.

avenantsoftware commented 8 years ago

With your new code I get an error:

node show-float.js /Users/htpc/node_modules/lgtv/index.js:296 if (hoststr.indexOf("ws://") !== 0) { ^

TypeError: hoststr.indexOf is not a function at _check_host_string (/Users/htpc/node_modules/lgtv/index.js:296:15) at Object.connect (/Users/htpc/node_modules/lgtv/index.js:314:10) at run_test (/Users/htpc/Source/lgtv.js/examples/show-float.js:4:8) at Object. (/Users/htpc/Source/lgtv.js/examples/show-float.js:15:1) at Module._compile (module.js:435:26) at Object.Module._extensions..js (module.js:442:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:311:12) at Function.Module.runMain (module.js:467:10) at startup (node.js:134:18)

msloth commented 8 years ago

What's your input? If I provide the function with a plain string, eg "hejhopp", it works as it should and I don't get that error, but if I provide eg {hostname: "hejhopp"}, ie not a string, then it doesn't and I get the same error you get. So, doublecheck your input, it should be lgtv.connect("hostname.lan", callback);

On a sidenote, I would love to hear how you (intend to) use the module! :)

msloth commented 8 years ago

Since hostname/ipaddress is now able to be set as an parameter to connect() and you can now connect, I mark this issue as solved. Cheers!